A Quick Guide to Continuous Integration and Continuous Delivery

Introduction

Continuous integration (CI) and continuous delivery (CD) incorporate values, set of operating principles, and collection of practices that enable application development teams to deliver changes more reliably and regularly; this is also known as pipeline.

What is Continuous Integration?

Continuous integration is an approach in which developers merge their code into a shared repository several times a day. For verification of the integrated code, automated tests and builds are run for it.

What is Continuous Delivery?

Continuous delivery is a strategy in which the development teams ensure the software is reliable to release at any time. On each commit, the software passes through the automated testing process. If it successfully passes the testing, it is then it is said to be ready for release into the production.

What is CI/CD Pipeline?

CI is the short form for Continuous Integration, and CD is the short form for Continuous Delivery. CI/CD Pipeline is a crucial part of the modern DevOps environment. The pipeline is a deployable path which the software follows on the way to its production with Continuous Integration and Continuous Delivery practices. It is a development lifecycle for software and includes the CI/CD pipeline, which has various stages or phases through which the software passes.

Version Control Phase

In this phase of the CI/CD pipeline, the code written by the developers is committed through a version control software or systems such as git, apache subversion, and more. It controls the commit history of the software code so that it can be changed if needed.

Build Phase

This phase is the first phase of this pipeline system. Developers build their code, and then they pass their code through the version control system or software. After this, the code returns to the build phase and gets compiled.

Unit Testing and Staging

When software reaches this stage, various tests are conducted on the software. One of the main tests is the Unit test, in which the units of software are tested. After successful testing, the staging phase begins. As the software has passed the tests to reach here, it is ready to be deployed into the staging process. Here, the software code is deployed to the staging environment/server. The code can be viewed and finalized here before the final tests can be conducted on the software.

Auto Testing Phase

After passing to the staging environment, another set of automated tests are prepared for the software. Only if the software completes these tests and is proved to be deployable, then it is sent to the next phase/stage, which is the deployment phase.

Deployment Phase

As the auto testing procedure is completed, then it is deployed to production. However, if any error occurs during the testing phase or the deployment phase, the software is sent to the version control procedure by the development team and checked for errors. If errors are found, then they need to be fixed. Other stages may be repeated if required.

What are the Continuous Integration and Continuous Delivery

The CI/CD process needs to be automated to get the best results. Various tools help us in automating the process so that it can be done precisely and with the least effort. These tools are mostly open-source and are designed to help with collaborative software development. Some of these tools are:

Jenkins is the most commonly used tool for the CI/CD process. It is one of the earliest and most powerful CI tools. It has various interfaces and inbuilt tools, which help us in the automation of the CI/CD process. At first, it was introduced as a part of a project named Hudson, which was released in 2005. Then it was officially released as Jenkins, in 2011. It has a vast plugin ecosystem, which helps in delivering the features that we need.

CircleCI is getting popular these days. It is becoming one of the best build platforms. It is hosted in the cloud and is a modern tool for the CI/CD process. One of its newest features is CircleCI Orbs. It has sharable code packages which help in setting the build pipeline easily and quickly.

It is a Continuous Integration tool. It is built into the GitLab, which is a web-based DevOps tool and provides a Git-repository manager, which helps in managing the git repositories. This was integrated into GitLab software after being a standalone project and was released in September 2015. Here, the CI/CD process is defined within a code repository. There are some tools named runners, which are used to complete the work. There are different executors that we can choose from while configuring runners like Docker, VirtualBox, and many more. It uses YAML configuration syntax to define the process in the repository.

It is one of the newest and smartest CI/CD tools. This tool is designed for the developers and helps in lowering the entry threshold in DevOps. It was officially launched in May 2015. Initially, its name was meat! which was changed to Buddy in November 2015. It was released as a cloud-only service. It does not use YAML configuration, but it supports .yml files.

It is an open-source tool and helps the development teams in the Continuous Delivery and Continuous Integration process. Initially released with name Cruise in 2007 by ThoughtWorks, it was renamed GoCD in 2010.

What is the CI/CD Process?

It is a process involving both continuous integration and continuous delivery. The process starts with continuous integration, and continuous delivery picks up where it ends. It involves a development approach named DevOps.

What are the Benefits of CI/CD?

Easy to debug and change

It is easier to debug and change the codes when there are small pieces of codes and continuously integrating. We can test these pieces while continuously integrating them with code repository.

Release and Delivery speed increases

With CI/CD, the speed of release and delivery is increased along with the development. Releases become more frequent and reliable.

Increased code quality

The quality of code increases as the code can be tested every time we integrate it with the code repository. The development becomes secure and more reliable. Also, CI/CD pipeline automates the integration and testing work, and more time can be spent on increasing the code quality.

Reduces the cost

CI/CD automates the development and testing process, so it reduces the effort of testing and integration. The errors are reduced due to automation, and it saves the time and cost of the developers. This saved time and cost can be applied to increase the code quality.

Increased Flexibility

With CI/CD, the errors are found quickly, and the product can be released more frequently. The flexibility to add new features increases. With automation, new changes can be adopted quickly and reliably.

What are the common pitfalls of CI/CD?

Wrong processes may be automated first

To shift from traditional models to DevOps, the existing organizations need to go through a transition process, which can be a long and difficult one. This process can take months, and even more if you don’t follow the right transition steps. The steps to adopt CI/CD, the steps can be prioritized based on the following points-

  • The repetition frequency of the process.
  • The dependencies involved in the process & delay produced by them.
  • Length of the process.
  • The urgency in process automation.
  • If the process is prone to errors if not automated.

These points can help in choosing processes to automate based on the priority.

Also, these points can help with the CI/CD testing process; we can get confused about whether to automate functional testing or UI testing. To make sure that the resources are used well, we should prioritize functional testing before UI testing.

Confusion between Continuous Deployment and Continuous Delivery

Many organizations fail to distinguish between continuous deployment and continuous delivery. They are two very different concepts. In the case of continuous deployment, the changes made in the code repository are passed through the pipeline, and if it is successful, the changes are immediately deployed to production. While in the case of continuous delivery, the changes made in code are built, tested, and then pushed to a non-production environment. In Continuous Deployment, deployment to the production environment is done without manual approval.

Inadequate coordination between continuous integration and continuous delivery

Continuous Delivery(CD) is the next step for Continuous integration(CI). They are two different items. But the implementation of CI/CD takes the collaboration of these two. Collaboration and communication cannot be automated.

Meaningful dashboards and metrics may be absent

In many cases, the scrum team may create a dashboard without proper progressive assessment, as a result of which, the team falls prey to the logical misconception that the given metrics must be important. The team may not know what to track and may follow the wrong metrics. Different members of a team may have different preferences. Some also prefer to use traffic indicators for the work. Some may not like the work that others have done.

So, creating meaningful and useful CI/CD dashboards may be tricky and extremely difficult, as some may not be satisfied with the work. Listening to everyone becomes difficult.

Requires new skillset

The process may be complicated for some developers and testers, who are working on traditional in-house software development techniques. It has two solutions, either re-train the employees for the automation process or hire new people who either know the processor can be trained for the process. Both of the solutions are a cost to the organization.

Maintenance is not easy

After the transition, maintenance is necessary to ensure that the pipeline is properly working, and there are no problems with the automation process. The bigger the organization, the difficult it is to maintain the pipelines for different services.

What are the Best Practices in CI/CD?

There are some practices in the case of the CI/CD process, which greatly enhance the performance of the process, and adhering to them can help in avoiding some common problems. These practices are:

CI/CD should be made the only way to deploy to production

In the case of CI/CD, the failures are immediately visible and the production is stopped until the cause of the failure is found and is corrected. It is an important mechanism and keeps further environments safe from the distrustful code. It is a process that is made solely for software development, integration, and delivery work, so it has advantages over other procedures, i.e., it is automated and hence faster.

Fastest tests should be the earliest to run

There are some tests which are comparatively faster than others. We should run these tests early. Running the fastest tests first helps in finding the errors faster. It is essential to find errors in software development as soon as possible to prevent further problems.

Running the tests locally before committing at CI/CD

The developers should adhere to the habit of running the tests locally before committing or sharing them at the CI/CD pipeline or shared repository. This step is beneficial as it helps in troubleshooting the software problems before it is shared with others and is an advantage for the developer.

Keeping the CI/CD pipelines fast

CI/CD pipelines are the core part of the CI/CD process; these are responsible for the faster integration and faster delivery process. We should find and apply methods to improve the speed and optimize the pipeline environment.

Conclusion

CI/CD is among the best practices for the devops teams to implement. Additionally, it’s an agile methodology; it facilitates the development team to achieve the business requirements, best code quality, and security because the steps of deployment are automated.

Originally published at https://www.xenonstack.com on January 27, 2020.

--

--

Xenonstack
Digital Transformation and Platform Engineering Insights

A Product Engineering and Technology Services company provides Digital enterprise services and solutions with DevOps , Big Data Analytics , Data Science and AI