Dhilip Venkatesh Uvarajan

Configuring Open API cache purge job on Jenkins - CCU V2

Blog Post created by Dhilip Venkatesh Uvarajan Champion on Sep 21, 2016

I was asking the question to myself, why Open API's can't be invoked from Jenkins or Postman like other REST API's.

 

Hitting Open API services using POSTMAN 

 

Open API's have sophisticated authentication mechanism which includes sending various auth headers, signing request body etc.. which is difficult to replicate with Jenkins/Postman. Also we needed to use one of Akamai's signing libraries from this link Open Source API Clients to talk to Edge servers.

 

Jenkins is a CI tool which is used to manage and schedule jobs/builds etc. I had a simple use case/workflow where I needed to purge Akamai cache after content deployment. Traditionally, we have a bunch of CP codes (35 of em) which we used to purge from Luna CCU post deployment. Logging into Luna and manually selecting each CP code was painful and caused lot of human errors.

 

I was looking for automation opportunities where I wanted a list of pre-defined CP codes to be automatically cleared after every successful content deployment. Idea was to trigger a Akamai content purge job from Jenkins after successful content deployment. Below I am documenting the steps taken for creating the Akamai purge job and running from Jenkins.

 

Pre-requisites:

============

 

One time Jenkins setup:

===================

 

Open API cache clear job:

=====================

  • All job params have been externalized to be passed from Jenkins.
  • Ability to cache clear array of CP codes or Arl's.
  • Ability to invalidate or remove cached content.
  • Ability to choose Akamai network (Prod/Stg) network for cache clear.
  • Pass the CP code in the format  '{"objects":[123456,654321],"action":"remove","type":"cpcode","domain":"production"}' 
  • For ARL  '{"objects":["http://www.test.com", "http://www.test123.com"],"action":"invalidate","type":"arl","domain":"production"}'
  • Parse the response object and get required information (Support ID, Purge ID etc..)
  • Once you have purge ID we can invoke /ccu/v2/purges/{purgeid} to get purge status.

 

#!/bin/bash

urlhost="https://akab-****.purge.akamaiapis.net"

response=$(python egcurl -sSik --eg-section ccu -X POST --data-binary "$1" -H "Content-type: application/json" -H "Accept: application/json" "$urlhost/ccu/v2/queues/default")

 

Setting up UI on Jenkins:

====================

  • I did choose to have drop down for (remove/invalidate) action.
  • Type can be cpcode/arl.
  • Domain can be staging/production.
  • Codes can contain array of CP codes/arl.

Outcomes