Apigee CICD Pipeline
This repository includes the instructions and pipeline definition for CI/CD using Jenkins, Apigee Lint, Apickli, Cucumber Reports, Slack & Apigee Maven Deploy plugin on Apigee.
Often the most difficult and confusing aspect of application development is figuring out how to build a common framework for creating/deploying new applications. Over time, development teams have started using tools like Maven to automate some of these functions. This repository uses various tools/plugins for deploying Apigee bundles to the Edge platform.
On every pipeline execution, the code goes through the following steps:
test
environment Apigee Edge UI, Download the proxy and push to Github. Github
.Apigee Lint
.apiproxy
directory goes through Unit Tests
done using mocha
.Istanbul/nyc
and reports are generated by Cobertura
.edge.json
configurations is created/updated and a new revision is published in prod
environment using Apigee Maven Build Plugin
.prod
environment goes through Integration tests using Apickli
.Cucumber Reports
are displayed in Jenkins.FAILS
, current revision is undeployed
and a stable revision is re-deployed
.Success/Fail
notification along with Cucumber reports
are sent to Slack Room
.HR-API.zip
proxy bundle from this repo/bundles & deploy to test
env or create an sample API Proxy.CiCd-Security.zip
proxy bundle from this repo/bundles & deploy to both prod
& test
environments.HR-API
directory & place your apiproxy
folder.username
, password
and base64encoded
string.ApigeeLint
will go through the apiproxy
folder,
apigeelint -s HR-API/apiproxy/ -f codeframe.js
Unit test any custom code within the proxy like Javascript
in our case. But it can be NodeJS
as well.
npm test test/unit/*.js
npm run coverage test/unit/*.js
Using Cobertura Plugin
in try-catch-finally block to generate reports in Jenkins.
cd coverage && cp cobertura-coverage.xml $WORKSPACE
step([$class: 'CoberturaPublisher', coberturaReportFile: 'cobertura-coverage.xml'])
Build & Deploy happens through Apigee Maven Plugin (update pom
and edge.json
files with appropiate details),
mvn -f HR-API/pom.xml install -Pprod -Dusername=${apigeeUsername} -Dpassword=${apigeePassword} -Dapigee.config.options=update
Integration tests happen through Apickli - Cucumber - Gherkin Tests,
cd $WORKSPACE/test/integration && npm install
cd $WORKSPACE/test/integration && npm test
Cucumber Reports plugin in Jenkins will use the reports.json
file to create HTML Reports & statistics.
If Integration tests fail, then through a undeploy.sh
shell script I am undoing Step 9. Through Jenkins Environment variable I am getting the current deployed revision and storing it as Stable revision
. Within Shell Script I am using this value to re-deploy in case of Failure.
curl -X DELETE --header "Authorization: Basic $base64encoded" "https://api.enterprise.apigee.com/v1/organizations/$org_name/environments/$env_name/apis/$api_name/revisions/$rev_num/deployments"
curl -X DELETE --header "Authorization: Basic $base64encoded" "https://api.enterprise.apigee.com/v1/organizations/$org_name/apis/$api_name/revisions/$rev_num"
curl -X POST --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: Basic $base64encoded" "https://api.enterprise.apigee.com/v1/organizations/$org_name/environments/$env_name/apis/$api_name/revisions/$stable_revision/deployments"
cucumber-reports
to Slack
I used cucumber-slack-notifier, but the pipeline cmd is not working as expected/documented. So for the time being I am running a separate FreeStyle project >> Build >> Send Cucumber Report to Slack
and point it to the reports.json in this pipeline directory.
build job: 'cucumber-report'
Integration Test
, we can add another Stage to Update Developer Portal Docs
. Apigee Drupal based portal
.Apigee Integrated Developer Portal
as of 14th July 2019.Performace/Load Tests
after Integrated Tests
dev >> uat >> prod
environments and use Jenkins to Merge and Commit updates.OAS
and use Apigee Management APIs to create and deploy a proxy through Pipeline.See the MIT LICENSE file.