Basic Apigee CICD Pipeline - updated

7 22 22.2K

Hi guys, I have updated my Apigee CICD repo on Github.

Pipeline steps,

  1. In Jenkins, Apigee Proxy bundle is cloned from Github.
  2. Static Code Analysis is done using Apigee Lint.
  3. Any Javascript files from apiproxy directory goes through Unit Tests using mocha.
  4. Code coverage is done by Istanbul/nyc and reports are generated by Cobertura.
  5. Using edge.json configurations are created/updated and 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. If the test FAILS, the current revision is undeployed and a stable/previous/hardcoded revision is re-deployed.
  9. Build Success/Fail notification along with Cucumber reports are sent to Slack Room.

For a detailed demo/steps/scripts, visit GitHub Repo.

8799-apigee-cicd-pipeline.png

8800-supporting-images.png

I would still like to modify the current pipeline and add new options in the future,

  1. Update Developer Portal.
    • After successful Integration Test, we can add another Stage to Update Developer Portal Docs.
    • Currently, we have plugin/apis for updating Apigee Drupal based portal.
    • We do not have any APIs for updating Apigee Integrated Developer Portal as of 14th July 2019.
  2. Add Performace/Load Tests after Integration Tests
  3. Use Git Branches/Projects for dev >> uat >> prod environments and use Jenkins to Merge and Commit updates.
  4. Use OAS with Apigee Management APIs to create and deploy a proxy through Pipeline.

********************************************************v1*********************************************************

6859-arch-diagram.jpg

Comments
Not applicable

@Siddharth Barahalikar - You have provided great details for creating Apigee pipeline. How much time did you need to establish this pipeline?

sidd-harth
Participant V

Hi @Hitesh Parikh, sorry for the delayed response. I somehow missed your query.

Well, it took me about a week to explore various docs & set up this pipeline.

babuk0930
Participant III

Do you have the latest updates too? as I see latest commit is one year old

sidd-harth
Participant V

I have plans to update it. But it is going to take sometime.

Are you looking for anything specific?

babuk0930
Participant III

Not yet. Just started to follow this. Will post here if I face any issue.

It would be great if you put up a video if possible.

babuk0930
Participant III

What exactly assertible is doing here? is that unit testing goes to assertible and then to apigee test?

sidd-harth
Participant V

At that time, I used Assertible as a first level basic testing, to check the status codes and input validation.

But it can be done using Apickli as well. So once you pull the proxy from github, I would suggest you do the static code analysis, then do Unit test for custom code like JS, Java, Python, Nodejs.

StaticCodeAnalysis >> Unit Test >> Deploy >> Performance/Integration testing >> Updating Docs

babuk0930
Participant III

For cucumber reports, do you have any specific config that needs to be changed in jenkins config other than plugin installation?

for me reports are not getting generated.

sidd-harth
Participant V

After APICKLI test, a reports.json file is generated. You need to copy that files to the workspace and then run a cucumber command. You can do that in finally block.

finally {
            // generate cucumber reports in both Test Pass/Fail scenario
            // to generate reports, cucumber plugin searches for an *.json file in Workspace by default
            bat "cd hr-api/test-dir/test/features && cp reports.json $WORKSPACE"
            cucumber fileIncludePattern: 'reports.json'


          }

babuk0930
Participant III

could you provide the whole updated jenkins file that you are executing in windows

Former Community Member
Not applicable

@Siddharth Barahalikar, I am looking at this repo for Jenkins job.

https://github.com/sidd-harth/apigee-cicd

If you have 1 Github repo for each proxy and a jenkinsfile in each repo, could you guide on how the job is setup on Jenkins? Are you using 1 proxy repo === 1 jenkins job?

Or would it be possible to use 1 Jenkins job for all proxy repos?

Thanks in advance.

sidd-harth
Participant V

I am not working on this currently so I dont have an updated Jenkinsfile.

Try it and let me know your issues, I will try to address them.

sidd-harth
Participant V

The repo you are looking at has only one proxy.

I have not tried 1 Jenkins job for all proxy repos. But I guess it can be done with this Jenkins Plugin Multiple SCMs Plugin

babuk0930
Participant III

Thanks able to do it finally.

Only thing i noticed is I need to add npm install before cucumber/apickli tests, in the same test folder. If I installed anywhere else, it fails.

sidd-harth
Participant V

I am glad that it worked for you.

Even I had issue with cucumber and I mentioned them in the Known/Current Issues at the end of Readme. I have rectified it in the new update.

I have started working on v2 of this project. I will update this thread in few days.

sidd-harth
Participant V

Hi @SatK, I updated my Repo, please have a look if required.

babuk0930
Participant III

question, where is this getting used. I see sendNotifications is configured in var, but where is this shared one

@Library('slackNotifications-shared-library@master') _
sidd-harth
Participant V

I am using a shared library to send slack notification. It reduces the repeated code in declarative pipeline.

Check this blog,

https://medium.com/@lvthillo/send-slack-notifications-in-jenkins-pipelines-using-a-shared-library-87...

babuk0930
Participant III

Thanks. One more question

  1. Any Javascript files from apiproxy directory goes through Unit Tests using mocha. - Setting the variables to js file and retrieving them. Is this the test you are doing here?
  2. Code coverage is done by Istanbul/nyc and reports are generated by Cobertura. - Didn't understand this. what is code coverage and what does it do?
itravindrasingh
Participant V

Hi @maneesh m,

I opinion on having 1 jenkin job for all the proxy would not be a good approach. if it fails it has to revert all the proxies and other configurations which is very difficult to trace, fix and deploy. So 1 proxy repo = 1 job would be much better.

Great article @Siddharth Barahalikar

caioisikawa
Explorer

@Siddharth Barahalikar, congratulations, it's a great article.
Just a question, as the pipeline is triggered by a github code update, how would a change thru apigee-ui trigger the pipeline ? I mean, every change made using apigee-ui would need to be exported and commited to github manually to trigger the pipeline ?

optimism
Participant V

Thank you for sharing info

Version history
Last update:
‎05-14-2018 11:55 AM
Updated by: