A practical guide to the continuous integration/continuous delivery (CI/CD) pipeline.
What is CI/CD?
CI/CD, which stands for continuous integration (CI) and continuous delivery (CD), creates a faster and more precise way of combining the work of different people into one cohesive product. In application development and operations (DevOps), CI/CD streamlines application coding, testing and deployment by giving teams a single repository for storing work and automation tools to consistently combine and test the code to ensure it works.
What is the CI/CD pipeline?
The continuous integration/continuous delivery (CI/CD) pipeline is an agile DevOps workflow focused on a frequent and reliable software delivery process. The methodology is iterative, rather than linear, which allows DevOps teams to write code, integrate it, run tests, deliver releases and deploy changes to the software collaboratively and in real-time.
A key characteristic of the CI/CD pipeline is the use of automation to ensure code quality. As the software changes progress through the pipeline, test automation is used to identify dependencies and other issues earlier, push code changes to different environments and deliver applications to production environments. Here, the automation’s job is to perform quality control, assessing everything from performance to API usage and security. This ensures the changes made by all team members are integrated comprehensively and perform as intended.
The ability to automate various phases of the CI/CD pipeline helps development teams improve quality, work faster and improve other DevOps metrics.
Benefits of the CI/CD pipeline
Automation of software releases — from initial testing to the final deployment — is a significant benefit of the CI/CD pipeline. Additional benefits of the CI/CD process for development teams include the following:
Reducing time to deployment through automation: Automated testing makes the development process more efficient, reducing the length of the software delivery process. In addition, continuous deployment and automated provisioning allow a developer’s changes to a cloud application to go live within minutes of writing them.
Decreasing the costs associated with traditional software development: Fast development, testing and production (facilitated by automation) means less time spent in development and, therefore, less cost.
Continuous feedback for improvement: The CI/CD pipeline is a continuous cycle of build, test and deploy. Every time code is tested, developers can quickly take action on the feedback and improve the code.
Improving the ability to address error detection earlier in the development process: In continuous integration, testing is automated for each version of code built to look for issues integration. These issues are easier to fix the earlier in the pipeline that they occur.
Improving team collaboration and system integration. Everyone on the team can change code, respond to feedback and quickly respond to any issues that occur.
Automation and how the CI/CD pipeline works
What is continuous integration?
The CI/CD process begins with continuous integration (CI). CI allows developers to work independently, creating their own coding “branch” to implement small changes. As the developer works, they can take snapshots of the source code, typically within a versioning tool like Git. The developer is free to work on new features; if a problem comes up, Git can easily revert the codebase to its previous state.
The work of individuals is then pushed into an automated system that uses scripts to build and test the code changes. After the build stage, a CI server compiles the source code changes into the master code or “trunk.”
Instead of writing code independently and submitting to the master once a month, which can lead to arduous work fixing bugs and poor version control, the CI/CD development process lets teams submit code changes more frequently. This continuous testing offers faster bug fixes, ensures functionality and, ultimately, results in better collaboration and software quality.
For a deeper dive into continuous integration, check out Eric Minick’s video on the subject:
The next step in the pipeline is continuous delivery (CD), which puts the validated code changes made in continuous integration into select environments or code repositories, such as GitHub. Here, the operations team can deploy them to a live production environment. The software and APIs are tested, and errors are resolved through an automated process. In the final step of the CD process, the DevOps team receives a notification about the latest build, and they manually send it to the deploy stage.
The goal of the continuous delivery pipeline stage is to deploy new code with minimal effort, but still allow a level of human oversight.
What is continuous deployment?
The CD in the CI/CD process also stands for continuous deployment. Continuous deployment automatically releases code changes to end-users after passing a series of predefined tests, such as integration tests that test code in a copycat environment to ensure code integrity.
Continuous delivery vs. continuous deployment
The difference between continuous delivery and continuous deployment is in the level of automation used in software or app releases. In continuous delivery, code automatically moves to production-like environments for further testing and quality assurance, and human intervention is required to move into production following successful tests. In continuous deployment, automation goes further. Once the code passes testing, the deployment to production happens automatically — there is no human approval needed.
For a closer look at the difference between continuous delivery and continuous deployment, check out this video:
How an organization applies the CI/CD pipeline and makes a decision on whether to use continuous delivery or deployment depends on its business needs. Continuous deployment is best for DevOps teams with a fast development lifecycle, such as for teams building ecommerce sites and SaaS platforms. Continuous deployment allows teams to release new or updated software often and as quickly as possible. Because changes are deployed to the public automatically, this type of continuous deployment pipeline is typically used only by DevOps teams that have a proven process.
For teams that may not need to release updates as frequently in their workflow — such as for those building healthcare applications — continuous delivery is typically the preferred option. It is slower but offers another layer of oversight to ensure functionality for the end-users.
The CI/CD pipeline phases
From source code to production, these phases make up the development lifecycle and workflow of the CI/CD pipeline:
Build: This phase is part of the continuous integration process and involves the creation and compiling of code. Teams build off of source code collaboratively and integrate new code while quickly determining any issues or conflicts.
Test: At this stage, teams test the code. Automated tests happen in both continuous delivery and deployment. These tests could include integration tests, unit tests, and regression tests.
Deliver: Here, an approved codebase is sent to a production environment. This stage is automated in continuous deployment and is only automated in continuous delivery after developer approval.
Deploy: Lastly, the changes are deployed and the final product moves into production. In continuous delivery, products or code are sent to repositories and then moved into production or deployment by human approval. In continuous deployment, this step is automated.
CI/CD tools and configuration
When selecting CI/CD tools, the focus should be on how to optimize and automate the software development process. An effective CI/CD pipeline uses open-source tools for integration, testing and deployment. Correct configuration of your CI/CD process also impacts the success of the software development pipeline.
The most common open-source CI/CD tool is Jenkins. Jenkins is an automated CI server written in Java and used for automating CI/CD steps and reporting. Other open-source tools for integration include Travis CI and CircleCI.
Integrated development environments (IDE), such as GitHub or AWS CodeCommit, help developers create, maintain and track software packages, while platforms like GitLab seek to provide the IDE within a comprehensive platform that includes other tools.
When operating in a cloud environment, teams use containers like Docker for packaging and shipping applications, and they use Kubernetes for orchestration. While Kubernetes isn’t strictly for the CI/CD pipeline, it is used in many CI/CD workflows.
The CI/CD pipeline and IBM
When it comes to being enterprise-ready, IBM Cloud Continuous Delivery is the cloud infrastructure and experience made for DevOps. Build, deploy and manage your applications with toolchains, pipelines and tool integrations designed for DevOps with the power of the cloud.
Less downtime, the ability to edit code from anywhere, assess deployment risk, and identify source code vulnerabilities are key benefits of DevOps teams on the cloud. IBM Cloud Continuous Delivery offers cloud-native DevOps tools as a service, fully hosted and managed on the IBM Cloud.