What is CI/CD? An Introduction to Continuous Integration, Continuous Deployment and CI/CD Pipeline
- June 17, 2019
Software and application development industry has gone through tremendous changes in the past decade.
From the good old days when software were installed on the desktop to the web-based SaaS applications. And the transition is not just seen in the way applications are used but also in the development methodologies — from the traditional waterfall development to Agile and the new trend of DevOps.
But all these changes and the introduction of new methods are aimed at one thing — to enhance the development process and provide better products to the end user.
CI (Continuous Integration) and CD (Continuous Delivery/Deployment) are such methods that are gaining momentum among developers using DevOps. In this article, we’ll discuss what exactly is CI/CD and how it can help you to develop better products.
What is CI/CD?
Understanding the Terms
Continuous Integration (CI) refers to committing (integrating) the code of individual developers — several times a day into a repository and run an automated test. What this does is, it helps to detect the issues and resolve them at a very early stage.
Continuous Delivery (CD) starts when the CI ends. Once the code is committed by the developers, they are uploaded on the staging server. Here, the application is checked to ensure that it’ll work well on the production server.
Continuous Deployment is a different concept than Continuous Delivery. CD here refers to the deployment of the built directly to the server after the code is committed and passes the test. Adopting Continuous Integration and Continuous Deployment enables producing new working software at a faster rate.
Traditionally, the developers used to work on isolated features of the application, submit the code and integrate it at the end of the cycle. This lead to spending several hours on tweaking the code and resolving issues to get it working. This task was quite daunting and cost the developers more time, efforts that resulted in deadline pressures. In the development world, this issue is known by the slang integration hell.
That’s when Continuous Integration comes it. It is a practice where developers integrate their code into the main branch of the repository several times a day. The code is then validated by creating a built and running automated tests. This continuous integration of small chunks of the codes — typically several times a day results in a seamless and easy integration that saves time and effort.
Benefits of Continuous Integration
- Automated tests detect bugs at an early stage so that you can ship a clean final product to the customers.
- Continuous Integration makes the release way easier and helps to avoid the integration hell.
- Automated tests can run a number of tests at a time that reduces the overall cost of testing.
- Even the quality analysts can focus on improving the quality of application cohesively rather spending time on testing and finding bugs.
What You Need to Practice
- Maintain a common code repository where the developers can commit code — such as GitHub and Gitlab.
- Automate the build.
- Configure the automated testing on the built package.
- Developers must commit the new code as often as possible typically several times a day.
Continuous Delivery is an extension of Continuous Integration. It is a practice that enables the developer to release the software on the production server with confidence.
Once the code is integrated, build and passes the automated tests, the built is pushed to the mock server. This enables the developer to check the application on the production-like environment and confidently upload it on the actual production environment — ensuring that the software will work well when it reaches to the customer.
The main goal of continuous delivery is to make the application deployment seamless, reduce risk and ensure the application will work great in the production environment. With CD, the application is always ready to deploy and there is no last-minute anxiety or urgency. Even the team can be confident about their codebase and can concentrate on their daily development tasks.
Benefits of Continuous Delivery
- Continuous Delivery makes the application deployment painlessly easier and the team no longer have to spend time on the release.
- It also reduces the risk of deploying the application with bugs as they are detected early on the production-like mock environment.
- Research has shown that CD making the releases easy and efficient reduces the burnout and ultimately makes the team happier.
- Releases can be made quicker and more often resulting in faster customer feedback and improving the product.
What You Need to Practice
- Your continuous integration must work well and the automated tests must cover enough codebase.
- Once the deployment is triggered, it must be fully automated without any need for human intervention.
- Incorporation of blue-green deployment or feature flags so that the incomplete features do not create downtime and affect the users.
While Continuous Delivery makes the codebase ready for the deployment, Continuous Deployment releases it directly to the production server.
Continuous deployment is a practice for application deployment wherein any code commit passing the automated testing is automatically released to the production server and made available to the users. This process of deployment is fully automated without any manual intervention — and the build components that don’t pass the production pipeline are prevented from deploying on the server.
This kind of automatic deployment works great to ship the new components and features of the application and bug fixes quickly to the customers. Users’ feedback is quick as customers stay in the loop with every update and even the team experiences peace of mind as there is no pressure of release date. Thus, ultimately developers can focus more on developing the application and see their work go live.
Benefits of Continous Deployment
- Deliver the new changes to the customers as soon as they are developed.
- You get an early ROI for the new feature as it is available to the users quickly soon after its development.
- Since small chunks of changes are released, it gets easier to fix the bugs.
- There is an incremental improvement in quality in a shorter period of time instead of quarterly or yearly improvements.
What You Need to Practice
- Incorporation of feature flags is an integral part of the process.
- The changes are released as soon as the code is committed, built and tested. So the quality of the new releases will be highly dependent on the testing.
What is CI/CD Pipeline?
Now you know that CI/CD is the strategies to ship well-tested applications frequently to the customers — and making the development process fast and efficient. However, the success of this discipline relies on a reliable CI/CD pipeline.
A CI/CD pipeline is the structure that automates the steps of the application delivery process. Since the process is automated, it removes the chances of committing any manual error and provides a quick product iteration. From a high-level view, the CI/CD pipeline includes steps such as — code commit, build, automated testing and deployment on staging and production server.
(An example of CI/CD Pipeline)
The pipeline starts with a common code repository where multiple developers working on the application commits their code several times a day. Some of the popular and widely used code repositories are GitHub, BitBucket, GitLab, Beanstalk and SourceForge.
Now, the changes are built using a built management system. The source code is combined to build a runnable component of the product.
3. Automate Testing
In this step, automated tests are run to check the codes. Automated testing plays an important role in the entire CI/CD pipeline and the success of delivering bug-free application depends on it. The code goes through varied tests depending on the complexity and needs of the project. We’ll discuss the type of tests in a few moments. Popular tools for automated testing are Telerik Test Studio, Selenium, Robotium, SoapUI and TestDrive.
Once the built passes through the automated tests, they’re ready to be deployed. The deployment can be either on the staging server, where the application is reviewed and additionally tested in the mock environment that is similar to the production environment. Or can be directly deployed onto the production server and made available to the users. Jenkins, Atlassian Bamboo, AWS CodeDeploy and CICircle are the majorly used tools.
(Deployment on the production-like staging server)
(Direct deployment on the production server)
The entire CI/CD pipeline is automated based on the needs of the project and organization. You can either adopt Continuous Delivery where the changes are uploaded on the mock server and then onto the production server or the highest level of automation — Continuous Deployment, where the changes are reflected in the production server automatically once the code is committed and passes the test.
Types of Automated Testings
Unequivocally, the key to successful continuous integration and continuous deployment/delivery is automated testing. And without it, there can be no successful CI/CD pipeline. These automated testing are divided into different types that serve their own purpose. The following are some of the tests included in automated testing, though it is not necessary to include every test at once.
- Unit Testing – Unit testing is done to test individual classes or functions.
- Integration Testing – Integration tests make sure that the multiple modules of the applications work well with each other.
- System Testing – System testing tests the entire system in an environment that replicates the real production environment.
- UI Testing – UI testing is performed to make sure the application works great as per the user’s perspective.
To wrap up, the ability to deliver the application, new features, components and bug fixes — quickly and efficiently is a necessity to stay ahead in the competition. And CI/CD is one such method that you can employ to meet the demands of modern software, web and mobile development. Once you put it in place and practice the right CI/CD principles, it can reap benefits for both your team as well as the end users.