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:
- Develop an API Proxy in
test
environment Apigee Edge UI, Download the proxy and push to Github. - In Jenkins, Apigee Proxy bundle is cloned from Github.
- Unit testing takes place in the
test
environment either using Newman or Assertible. - Code Analysis is done using Apigee Lint.
- A new revision is published in
prod
environment using Apigee Maven Build Plugin. - The newly deployed
prod
environment goes through Integration tests using Apickli. - Apickli produced Cucumber Reports are displayed in Jenkins
- Build Success/Fail notification is sent to Slack Room.
The following diagram shows the steps included in the deployment pipeline:
- Apigee Edge Account
- Assertible Account + Jenkins Config
- Slack Account + Jenkins Config
- NodeJS & NPM
- Configure Jenkins with Git, Cucumber Reports, JDK, Maven, NodeJS, Slack Plugins
- HR API - Which does do all CRUD operations on employee records. For backend I am using Apigee BaaS.
- You can use any backend of your preference or simply mock the data using Assign Message Policy.
- Download
hr-api_rev1_test_env.zip
from this repo & deployed totest
env or create an sample API Proxy. - Clone/Fork this repo & Create a directory structure as per
hr-api
directory & place yourapiproxy
folder. - In Jenkins as of 14th May, 2018 I am not using Git SCM due to some Jenkins issue(this will be rectified ASAP). I have manually copy-pasted my Jenkinsfile Script in my Pipeline Job.
- Trigger Build Manually. First Assertible will run through the unit tests.
curl -u apikey: 'https://assertible.com/deployments' -d'{\"service\":\"d8d73-b0a94b325ae4\",\"environmentName\":\"production\",\"version\":\"v1\"}'
- Apigee Lint will go through the
apiproxy
folder,
apigeelint -s /hr-api/apiproxy/ -f table.js
8. Build & Deploy happens through Apigee Maven Plugin(update
pom
files with appropiate details),
mvn -f /hr-api/pom.xml install -Pprod -Dusername=<email_here> -Dpassword=<password_here>
9. Integration tests happen through Apickli - Cucumber - Gherkin Tests,
cucumber-js --format json:reports.json features/prod_tests.feature
-
Cucumber Reports plugin in Jenkins will use the
reports.json
file to create HTML Reports & satistics. -
If Integration tests fail, then through a
undeploy.sh
shell script I am undoing Step 8.
curl -X DELETE --header "Authorization: Basic <base64 username:password>" "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 <base64 username:password>" "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 <base64 username:password>" "https://api.enterprise.apigee.com/v1/organizations/$org_name/environments/$env_name/apis/$api_name/revisions/$pre_rev/deployments"
- Git Plugin issue with Jenkins. Hence a lot of manual steps had to be done in Jenkinsfile. Working on a solution, will update this Jenkinsfile.
- Cucumber Tests don't run/work in local directory. It only works from global directory /usr/node_modules/npm/ directory