heidloff.net - Building is my Passion
Post
Cancel

Reducing Deployment Risks via Policies for Jenkins Pipelines

Earlier this year IBM introduced a new service DevOps Insights (beta) which helps among other things to reduce deployment risks. Policies can be defined to ensure that unit tests, functional tests and other tests pass before new versions of applications are deployed.

As I blogged earlier this functionality can be used for IBM DevOps Delivery Pipelines. Additionally it can also be used for Jenkins projects since data can be sent from Jenkins to other tools like IBM DevOps Insights that are in the same toolchain.

In the following example a gate has been defined with a policy to enforce that all unit tests pass before the application can be deployed into production.

jenkins-risk3

For demo purposes I broke some unit tests. The following screenshot shows that in this case the gate stage fails.

jenkins-risk7

Check out the Jenkinsfile how to leverage the gate.

1
2
3
4
5
6
stage('Gate') {
   steps {
      // use "evaluateGate" method to leverage IBM Cloud DevOps gate
      evaluateGate policy: 'Weather App Policy', forceDecision: 'true'
   }
}

You can also see the build and deployment status on the Deployment Risk page of the DevOps Insights service.

jenkins-risk6

In order to try this functionality yourself, you can follow these high level steps:

  • Set up a local Jenkins Docker container, install the CF CLI and configure Jenkins
  • Open bluemix.net/devops and create a new toolchain based on the sample “Deployment Risk Analytics with GitHub and Jenkins”
  • Fork the GitHub project that comes with a sample weather application, a Jenkinsfile and various types of tests
  • Replace the values of the environment variables at the top of the Jenkinsfile
  • In Jenkins create a new Pipeline project and paste the Jenkinsfile as the pipeline script
  • Run the build

In order to demo a failure you can break unit tests by replacing the unit tests JavaScript file with this file.

Thanks a lot to my colleagues Eric Jodet, Xunrong Li and Vijay Jegaselvan for helping me setting this up and providing the sample application!

Featured Blog Posts
Disclaimer
The postings on this site are my own and don’t necessarily represent IBM’s positions, strategies or opinions.
Trending Tags