CI/CD Pipeline: Learn with Example - Shikshaglobe

Content Creator: Vijay Kumar

What is a CI/CD pipeline?

A CI/CD pipeline computerizes the course of programming conveyance. It constructs code, runs tests, and assists you with securely conveying another variant of the product. CI/CD pipeline diminishes manual mistakes, gives input to engineers, and permits quick item emphasis.


CI/CD pipeline presents mechanization and nonstop checking all through the lifecycle of a product item. It includes from the mix and testing stage to conveyance and organization. These associated rehearses allude to CI/CD pipeline.

In the world of software development, Continuous Integration and Continuous Deployment (CI/CD) have become essential practices for delivering high-quality software rapidly. In this tutorial, we will dive into the concept of CI/CD pipelines by building a simple example.

What is a CI/CD Pipeline?

A CI/CD pipeline is an automated process that facilitates the integration of code changes into a shared repository (Continuous Integration) and the automated deployment of code to production or other environments (Continuous Deployment). It ensures that code is built, tested, and deployed consistently and reliably.

Prerequisites

Before we begin, ensure you have the following:

  • A version control system (e.g., Git)
  • A code repository (e.g., GitHub)
  • A CI/CD tool (e.g., Jenkins, Travis CI, GitLab CI/CD)
  • A target environment for deployment (e.g., a server or cloud platform)

Building a Simple CI/CD Pipeline

Let's create a basic CI/CD pipeline for a hypothetical web application. We'll use GitHub for version control and Travis CI for automation. Here's a step-by-step guide:

Step 1: Setting Up Your Repository

1.     Create a new GitHub repository for your web application.

2.     Push your code to the repository.

Keep reading

Step 2: Configuring Travis CI

1.     Sign in to Travis CI using your GitHub account.

2.     Enable the GitHub repository you just created in your Travis CI account.

3.     Create a .travis.yml file in your repository. This file contains configuration details for your CI/CD pipeline.

1.     This example uses Node.js, but you can adjust it for your specific technology stack.

Step 3: Automating Testing

1.     In your application code, create unit tests using a testing framework like Jest, Mocha, or Jasmine.

2.     Modify the .travis.yml file to run your tests during the CI process.

Step 4: Deployment

Decide where you want to deploy your application (e.g., a cloud server, a platform-as-a-service like Heroku, or a containerized environment).

 

Click here to find out more

Set up the necessary deployment scripts and credentials.

 

Modify the .travis.yml file to include deployment instructions.

Step 5: Pushing Code and Triggering the Pipeline

1.     Commit your changes to your GitHub repository.

2.     Push the changes to your GitHub repository.

3.     Travis CI will automatically detect the push and start the CI/CD pipeline.

Step 6: Monitoring

1.     Monitor the Travis CI build process through the Travis CI dashboard.

2.     If the build and tests are successful, your application will be deployed to the specified environment.

What are Continuous Integration, Continuous Delivery, and Continuous Deployment?

The ceaseless mix is a product improvement strategy where individuals from the group can coordinate their work something like one time each day. In this technique, each joining is actually taken a look at by a robotized work to look through the blunder.

Consistent conveyance is a programming technique where a group creates programming items in a short cycle. It guarantees that the product can be handily delivered whenever.

Consistent sending is a programming cycle in which item functionalities are conveyed utilizing programmed organization. It assists analyzers with approving whether the codebase changes are right, and it is steady or not.

Take the next step

Phases of a CI/CD pipeline

A CI/CD pipeline is a runnable detail of the means that any designer ought to perform to convey another rendition of any product. Disappointment in every single stage sets off a notice through email, Slack, or other correspondence stages. It empowers capable engineers to be aware of the significant issues.


Here are the significant Stages of the CI/CD pipeline:


Source Stage

In the source stage, CI/CD pipeline is set off by a code store. Any adjustment of the program sets off a notice to the CI/CD instrument that runs a comparable pipeline. Other normal triggers incorporate client-started work processes, mechanized plans, and the consequences of different pipelines.


Fabricate Stage

This is the second phase of the CI/CD Pipeline in which you combine the source code and its conditions. It is done predominantly to construct a runnable occurrence of programming that you might possibly transport to the end client.


Programs that are written in dialects like C++, Java, C, or Go language ought to be gathered. Then again, JavaScript, Python, and Ruby projects can work without the forming stage.


Inability to pass the forming stage implies there is a key task misconfiguration, so it is better that you address such an issue right away.


Test Stage

Test Stage incorporates the execution of mechanized tests to approve the accuracy of code and the way of behaving of the product. This stage keeps effectively reproducible bugs from arriving at the clients. It is the obligation of engineers to compose computerized tests.


Send Stage

Here your item goes live. When the form has effectively finished through all the expected assessment situations, it is prepared to convey to live server.


Illustration of CI/CD Pipeline

Here is an illustration of the CI/CD pipeline:


Source Code Control: Host code on GitHub as a confidential vault. This will assist you to incorporate your application with significant administration and programming.

Constant reconciliation: Use ceaseless combination and conveyance stage CircleCI and commit each code. At the point when the progressions advise, this apparatus will pull the code accessible in GitHub and cycle to fabricate and run the test.

Send code to UAT: Configure CircleCI to convey your code to the AWS UAT server.

Convey to creation: You need to reuse consistent mix ventures for sending code to UAT.

CI/CD pipeline Best Practices


Here is a CI/CD pipeline best practices:

Review the ongoing improvement process subsequently, you can know the techniques that expect to change and one that can be effectively mechanized.

Get going with a little confirmation of undertaking prior to feeling free to finish the entire improvement process on the double.

Set up a pipeline with more than one phase in which quick principal tests run first.

Begin every work process from something similar, clean, and separate climate.

Run open source devices that cover all that from code style to security checking.

Arrange a superior code center point to really look at the nature of your code by running the standard arrangement of tests against each branch persistently.


Peer code survey each pull solicitation to tackle an issue in a cooperative way.

You need to characterize achievement measurements before you start the change to CD mechanization. This will assist you with reliably breaking down your product, creating progress help refine where required.


Benefits of CI/CD pipelines

Here are the masters/advantages of the CI/CD Pipeline:

Constructs and testing can be effectively performed physically.

It can work on the consistency and nature of code.

Further develops adaptability and can deliver new functionalities.

CI/CD pipeline can smooth out correspondence.

It can computerize the course of programming conveyance.

Assists you with accomplishing quicker client input.

CI/CD pipeline assists you with expanding your item perceivability.

It empowers you to eliminate manual blunders.

Diminishes expenses and work.

CI/CD pipelines can make the product advancement lifecycle quicker.

It has a computerized pipeline arrangement.

A CD pipeline gives a quick input circle beginning from engineer to client.

Further develops correspondences between association workers.

It empowers designers to realize which changes in the form can go to the financier and to keep away from them later on.

The robotized tests, alongside not many manual trials, help to fix any issues that might emerge.


Significant CI/CD instruments

Here are the significant CI/CD instruments:

Jenkins

Jenkins is an open-source Continuous Integration server that assists with accomplishing the Continuous Integration process (and not just) in a computerized style. Jenkins is free and is totally written in Java. Jenkins is a broadly utilized application all over the planet that has around 300k establishments and developing step by step.


Highlights:

Jenkin will construct and test code ordinarily during the day.

Mechanized form and test process, saving timing, and lessening absconds.

The code is conveyed after each effective form and test.

The advancement cycle is quick.


Bamboo

Bamboo is a constant joining fabricate server that performs - programmed construct, tests, and deliveries in a solitary spot. It works consistently with JIRA programming and Bitbucket.


Highlights:

Run equal clump tests

It is easy to Set up Bamboo

Per-climate consents highlight permits engineers and QA to convey to their surroundings

Inherent Git stretching and work processes. It naturally consolidates the branches.


CircleCi

CircleCi is an adaptable CI device that runs in any climate like a cross-stage versatile application, Python API waiter, or Docker group. This apparatus decreases messes with and works on the nature of the application.


Highlights:

Permits to choose Build Environment

Upholds numerous dialects including C++, JavaScript, NET, PHP, Python, and Ruby

Support for Docker allows you to design a modified climate.

Naturally, drop any lined or running forms when a fresher form is set off.


For what reason Does the CI/CD Pipeline Matter for IT Leaders?

CI/CD pipeline can further develop unwavering quality.

It makes the IT groups more alluring to designers.

CI/CD pipeline helps IT pioneers, to pull code from rendition control and execute programming fabricate.

Assists with moving code to target processing climate.

Empowers project pioneers to effectively oversee climate factors and arrange for the objective climate.

Project directors can distribute push application parts to administrations like web administrations, data set administrations, API administrations, and so on.

Give log information and alarms on the conveyance state.

It empowers software engineers to check code changes before they push ahead, diminishing the possibilities of deformities winding up underway.


Ci/CD Pipeline KPI

Cycle or Deployment Time: Cycle time is the time taken to go from the formation stage to creation. You can acquire normal life process duration by estimating the improvement interaction stages. This measurement will give knowledge about bottlenecks in your cycle and the general speed of advancement time.

Advancement Frequency: Development recurrence permits you to dissect bottlenecks you find during computerization. The more regular more modest deliveries lessen the gamble of deformities and fix them when found. Such a measurement is a general proportion of your group productivity.

Change Lead Time: It estimates the beginning season of the improvement stage of the arrangement. This measurement is a sign of the whole improvement interaction and how well the group cooperates.

Change Failure Rate: It centers around the time improvement get succeeds versus the times it falls flat.

MTTR versus MTTF: MTTR (Mean Time to Recovery) is how much time is expected by your group to recuperate from disappointment. MTTF (Mean Time to Failure) gauges how much time among fixes and blackouts. These measurements are an impression of the group's capacity to answer and fix issues.


Rundown

A CI/CD pipeline robotizes the course of programming conveyance.

CI/CD pipeline presents mechanization and ceaseless observing all through the lifecycle of a product item.

Persistent reconciliation is a product improvement technique where individuals from the group can incorporate their work no less than one time per day.

Consistent conveyance is a programming strategy where a group creates programming items in a short cycle.

Consistent sending is a programming cycle in which item functionalities are conveyed utilizing programmed organization.

There are four phases of a CI/CD pipeline 1) Source Stage, 2) Build Stage, 3) Test Stage and 4) Deploy Stage.

Significant CI/CD apparatuses are Jenkins, Bambo, and Circle CI.

CI/CD pipeline can further develop dependability.

CI/CD pipeline makes IT group more alluring to designers.

Process duration is the time taken to go from the formation stage to creation.

Improvement recurrence permits you to dissect bottlenecks you find during mechanization.

Change Lead Time estimates the beginning season of the development

Read More Information:

Jenkins Freestyle Project
Software Engineer vs Software Developer: What’s The Difference
Capability Maturity Model (CMM) & it’s Levels in Software Engineering
How to Install Git Plugin in Jenkins

Featured Universities

Mahatma Gandhi University

Location: Soreng ,Sikkim , India
Approved: UGC
Course Offered: UG and PG

MATS University

Location: Raipur, Chhattisgarh, India
Approved: UGC
Course Offered: UG and PG

Kalinga University

Location: Raipur, Chhattisgarh,India
Approved: UGC
Course Offered: UG and PG

Vinayaka Missions Sikkim University

Location: Gangtok, Sikkim, India
Approved: UGC
Course Offered: UG and PG

Sabarmati University

Location: Ahmedabad, Gujarat, India
Approved: UGC
Course Offered: UG and PG

Arni University

Location: Tanda, Himachal Pradesh, India.
Approved: UGC
Course Offered: UG and PG

Capital University

Location: Jhumri Telaiya Jharkhand,India
Approved: UGC
Course Offered: UG and PG

Glocal University

Location: Saharanpur, UP, India.
Approved: UGC
Course Offered: UG and PG

Himalayan Garhwal University

Location: PG, Uttarakhand, India
Approved: UGC
Course Offered: UG and PG

Sikkim Professional University

Location: Sikkim, India
Approved: UGC
Course Offered: UG and PG

North East Frontier Technical University

Location: Aalo, AP ,India
Approved: UGC
Course Offered: UG and PG