Code Monkey home page Code Monkey logo

apigee-cicd's Introduction

!! incomplete steps !! futher refining is required !!

CI/CD Demo - Apigee API Management Platform

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.

Introduction

On every pipeline execution, the code goes through the following steps:

  1. Develop an API Proxy in test environment Apigee Edge UI, Download the proxy and push to Github.
  2. In Jenkins, Apigee Proxy bundle is cloned from Github.
  3. Unit testing takes place in the test environment either using Newman or Assertible.
  4. Code Analysis is done using Apigee Lint.
  5. A new revision is published in prod environment using Apigee Maven Build Plugin.
  6. The newly deployed prod environment goes through Integration tests using Apickli.
  7. Apickli produced Cucumber Reports are displayed in Jenkins
  8. Build Success/Fail notification is sent to Slack Room.

The following diagram shows the steps included in the deployment pipeline: arch_diagram

Prerequisites

Demo Guide

  1. HR API - Which does do all CRUD operations on employee records. For backend I am using Apigee BaaS.
  2. You can use any backend of your preference or simply mock the data using Assign Message Policy.
  3. Download hr-api_rev1_test_env.zip from this repo & deployed to test env or create an sample API Proxy.
  4. Clone/Fork this repo & Create a directory structure as per hr-api directory & place your apiproxy folder.
  5. 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.
  6. 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\"}'
  1. Apigee Lint will go through the apiproxy folder,
apigeelint -s /hr-api/apiproxy/ -f table.js

apigee-lint 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>

maven-build 9. Integration tests happen through Apickli - Cucumber - Gherkin Tests,

cucumber-js --format json:reports.json features/prod_tests.feature
  1. Cucumber Reports plugin in Jenkins will use the reports.json file to create HTML Reports & satistics. cucumber-tag-fail cucumber-failure

  2. 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"
  1. When Build Starts/Ends & At any step if a Failure occurs, a notification is sent to Slack Room. slack-web

Known/Current Issues

  1. 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.
  2. Cucumber Tests don't run/work in local directory. It only works from global directory /usr/node_modules/npm/ directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.