<img alt="" src="https://secure.hiss3lark.com/167682.png" style="display:none;">
  • share

A blog about software development best practices, how-tos, and tips from practitioners.

CI/CD Pipeline: Oxygen for Agility

CI/CD Pipeline: Oxygen for Agility

“If Ops goes to lunch with Ops and Dev goes to lunch with Dev, a low level of efficiency is a certainty”-anonymous.

 Like this quote, if both Dev (development) and Ops (operation) goes in different directions, it creates mayhem. So DevOps is a goal to achieve; it’s a never-end process to accelerate continuous improvement. DevOps integrate software development and operations on one platform to deliver state-of-the-art application on time.CI/CD

CI and CD i.e. Continuous Integration and Continuous Deployment are the cornerstones of modern DevOps operation. This approach believes in automating everything including test, build, and deployment to link the gap between development and operation. Before understanding the CI/CD pipeline let’s have a short glimpse of DevOps.   

Understanding DevOps

DevOps is a modern software development approach with a push of doing everything continuously for high-quality application delivery within a short period. The DevOps development lifecycle includes continuous (development, testing, integration, deployment, and monitoring).DevOps

What is CI/CD?

Pipeline terminology concerning Continuous Integration/Continuous Delivery is a set of activities channelized to be executed in a timely & step-wise or stage-wise manner periodically in the Software Development Phase. Before getting in more insights about Pipeline, at first let us understand what is CI & CD first in the context of Software Development.

CI term is a short form of Continuous Integration. CI is a process where the code is integrated into a shared repository, reviewed for coding standards & unit tested frequently to keep a check on an error-free code.

And the CD term is a short form of Continuous Delivery. CD process is performed in conjunction with the CI process. It is an activity to deploy the code or changes in staging or production environments on a subsequent basis.

What is CI/CD Pipeline?

In short, the CI/CD Pipeline is a path to execute each of the CI & CD activities in a gradual or step-wise manner.

CI/CD Pipeline is one of the essential aspects of DevOps in Software Development. It systematically channelizes development & delivery activities efficiently. The basic building block of Pipeline cycle recursively evolves around:

CODE > BUILD > TEST > DEPLOY > INTEGRATE & OPERATE > MONITOR

Components/Building Blocks of CI/CD Pipeline

The following are basic components or building blocks, associated with CI/CD pipeline. Let’s understand how these components contribute towards a quick delivery of apps in no time.

Version Control

Version Control is an activity to maintain versions or revisions of each piece of code committed by the development team. Such code commits are managed via various version controlling systems such as GIT, Mercurial, SVN, TFS, etc.

In this block, versions or tags are specified for the code or block of code to be delivered. Along with Version Controlling, detailed code review & coding standards (in an automated approach) is also done in the phase. 

Build

The build is the phase where code compilation (if applicable) takes place. The code compilation process relies on the programming languages.

Unit Test

The build phase is followed by the testing phase. In this phase, various testing activities are performed in an automated way:

  1. Unit Testing: Individual units or components are checked
  2. Sanity Testing: Unscripted tests to know about missing dependent functionality.

Deploy

In this phase, code traverses to a staging server after passing through unit tests.

Review Test

Once again single round of unit testing is carried out to confirm the functionalities of the code.

Deploy to Production

In this phase, the code is deployed on the production server.

Monitor

The final phase in this process is monitoring or validating if the process of deployment is smoothly transitioned or not. Also, if any of the above activity fails then email & notification mechanism is available/present for alerting the respective stakeholders & development team.

Refer to the following block diagram to understand the processing in a graphical way:Building Blocks of CI/CD Pipeline

Why CI/CD Pipeline is essentials?

CI/CD Pipeline is an essential process for the following reasons:

  • Developers can focus on code and dependencies, not on configuration & deployment.
  • Automated code review & coding standards check can ensure good coding practice & ensure coding standards being followed.
  • The entire testing process gets automated and the testing team only needs to concentrate on writing effective test cases.
  • This is a recurrently occurring process thus systematic continuous/frequent evaluation process will be in place.

Pipeline Concept with Jenkins

Jenkins Pipeline is a package of plugins to assist in implementing & integrating constant delivery pipelines. It offers extensible tools set for modeling simple and complex delivery pipelines "as code" via the Pipeline DSL.

Jenkins Pipeline Prerequisites

  1. Jenkins Version 2.x.x
  2. Pipeline plugin

Defining a Pipeline

Pipeline (both declarative & scripted) are DSLs (Domain Specific Language). To write this DSL Groovy syntax is used. Using Groovy-based commands, you can write the process flow of your pipeline process.

Illustrative Example of Setting a Pipeline Job in Jenkins

Step 1:

  • Add a new job in Jenkins
  • Login to the Jenkins Dashboard > (Click on) New Job > Enter an item name > (Select) Pipeline Option.Jenkins
  • Once a new Job is added, then click on the Job title to view the Job edit page.

Step 2:

  1. Then Go to “Configure > Pipeline tab”.
  2. In the Pipeline tab, you can specify pipeline script to be used to drive this job. For this you will have two options:
  • Use pipeline script hosted in your GIT repository.
  • Directly add the pipeline script within the text area provided.

For this illustration, we shall add our pipeline script in the text area. Once we are done with adding, click on the Save button. This will save the job.Pipeline tabStep 3:

Now, to test this job, click on the “Build Now” link. This will trigger the job execution & would execute each stage specified in the pipeline script. Once the job execution is done, you can check the latest build executed in build history & click “Console Output”.


In the console output, we can note the execution of each stage along with their output.console output

The above illustration is a mere demonstration about usage of Pipeline concept. However, the script can be more effectively written to handle much more complex activities.

 

Conclusion

Well, this is what CI/CD Pipeline is comprised of. The above description is an abstractive explanation of the pipelines concept. For detailed input please refer to the “jenkin.io” site. We hope this piece of information serves to be helpful for understanding CI/CD pipeline specially and DevOps culture in general.

Reference

https://jenkins.io/doc/book/pipeline/

https://jenkins.io/doc/book/pipeline/syntax/

Generic-CTA-01

Like what you just read? Get Latest content delivered straight to your inbox.