Walkthrough - Quick Implementation of MultiBranch CICD

I had an opportunity to learn about Continuous Integration and Deployment pipelines. I was interested to get this done with less code. Hence, the aim of this walkthrough is to:

  • Understand, how CI/ CD Pipeline is implemented at its basic level
  • Explore Blue Ocean Plugin for Jenkins (UI available as plugin in Jenkins)

To accomplish the above, the best way is to implement it by myself. 

Sample Use Case

In an agile world, software's and their components are continuously integrated, tested and deployed. Developers write code in the form of features which need to be tested. In the end, each completed unit or chunk should be integrated in a big chunk of software aka. Software release.  Each developer works on his feature branch which later needs to be reviewed via a Pull request.

Now, the process of reviewing features (code) written by multiple developers and deploying them several times is a time taking process. Automating such processes not only help the developers but also enable companies to bring their software increments quickly in the market.

 Below is the high level illustration depicting how feature branches are eventually merged with the release.

No alt text provided for this image

To make the process simple, I tried to create a three steps Jenkins pipeline:

Build → Test → Deploy

Build Step - Checkout latest source code from the version control, compile it and generate deployable artifacts 

Test Step - Execute JUnit or Integration Testing against the generated artifacts (from Build Step)

Deploy Step  - Deploy the same artifact on staging or production environments 

Pre-requisites

1. Jenkins

2. Install Jenkins Plugin - Blue ocean (https://plugins.jenkins.io/blueocean/)

3. Branches available in a source code version control - GitHub, Bitbucket, GitLab

Create Jenkins Multi Branch Pipeline

  • Go to New Items option
No alt text provided for this image
  • Enter Multibranch Pipeline name and select option Multibranch Pipeline then Click on OK button
No alt text provided for this image
  • Below are the configuration of Multibranch Pipeline, enter required configuration such as git repo
No alt text provided for this image
No alt text provided for this image

 Create Jenkinsfile

  • Below is the sample jenkinsfile - used by Jenkins
  • The file shows three steps Jenkins pipeline:  Build → Test → Deploy

Note: For the sake of the example, tests are skipped in the Test stage. Similarly, Deploy stage only prints text on the console.

No alt text provided for this image
  • Above jenkinsfile should be placed in the repository as shown below
No alt text provided for this image
  • Commit your changes to the repository- This will trigger the Jenkins recently job
  • After completing all implementation and configuration, go to Jenkins  → Click on Open Blue Ocean
No alt text provided for this image

GitHub Branches

  • GitHub branches which we want to use in Jenkins 
No alt text provided for this image
  • The Multi branch pipeline job is My-Automation and all GitHub branches in Jenkins via Blue Ocean are visible.
No alt text provided for this image

Pull Request Option

  • Through the Pull Requests option, PR and PR Status of branches along-with some additional information such as  author name and completed time or day
No alt text provided for this image
  • Go into branch PR example Develop, the build pipeline flow is opened, and the build pipeline steps can be seen, defined in in jenkinsfile. We have currently three steps:

Build 🡪 Test 🡪 Deploy

No alt text provided for this image

At each step, tasks or operations which are  executed are visible. For Instance, clicking on the build step will show the build logs. Same goes for the Test and Deploy step.

Conclusion

In my opinion, one can easily implement basic CI and Release pipelines via BlueOcean Plugin without writing too much code.

To view or add a comment, sign in

Others also viewed

Explore content categories