Skip to content

What is CI/CD

From docker image to EKS

CI and CD stand for continuous integration and continuous delivery/continuous deployment. In very simple terms, CI is a modern software development practice in which incremental code changes are made frequently and reliably. Automated build-and-test steps triggered by CI ensure that code changes being merged into the repository are reliable. The code is then delivered quickly and seamlessly as a part of the CD process. In the software world, the CI/CD pipeline refers to the automation that enables incremental code changes from developers’ desktops to be delivered quickly and reliably to production.

What is continuous integration (CI)?

Continuous integration is the practice of integrating all code changes into the main branch of a shared source code repository early and often. Each change is automatically tested when you commit or merge it, and a build is automatically triggered. Continuous integration makes it easier to identify and fix errors and security issues much earlier in the development process.

By merging changes frequently and triggering automatic testing and validation processes, you minimize the possibility of code conflicts, even when multiple developers are working on the same application. A secondary benefit is that you don’t have to wait long for answers and can fix bugs and security issues while the topic is still fresh in your mind.

Common code validation processes begin with a static code analysis that verifies the quality of the code. Once the code passes the static tests, automated CI routines package and compile the code for further automated testing. CI processes should have a version control system that tracks changes so you know the version of the code used.

What is continuous delivery (CD)?

Continuous delivery is a software development practice that works in conjunction with CI to automate the infrastructure provisioning and application release process.

Once code has been tested and built as part of the CI process, CD takes over during the final stages to ensure it’s packaged with everything it needs to be deployed to any environment at any time. CD can cover everything from provisioning the infrastructure to deploying the application to the testing or production environment.

With CD, the software is built so that it can be deployed to production at any time. You can either trigger the deployments manually or move to continuous deployment, where deployments are automated as well.

What is Continuous Deployment?

Continuous deployment enables organizations to automatically deploy their applications, eliminating the need for human intervention. With continuous deployment, DevOps teams set the criteria for code releases ahead of time. When those criteria are met and validated, the code is deployed into the production environment. This allows organizations to be more nimble and to get new features into the hands of users faster.

While you can do continuous integration without continuous delivery or deployment, you can’t really do CD without already having CI in place. That’s because it would be extremely difficult to deploy to production at any time if you aren’t practicing CI fundamentals like integrating code to a shared repo, automating testing and builds, and doing it all in small batches on a daily basis.

What is Continuous Testing?

Continuous testing is a software testing practice where tests are continuously run to identify bugs as soon as they are introduced into the codebase. In a CI/CD pipeline, continuous testing is typically performed automatically, with each code change triggering a series of tests to ensure that the application is still working as expected. This can help to identify problems early in the development process and prevent them from becoming more difficult and costly to fix later on. Continuous testing can also provide valuable feedback to developers about the quality of their code, helping them to identify and address potential issues before they are released to production.

In continuous testing, various types of tests are performed within the CI/CD pipeline. These can include:

  • Unit testing, which checks that individual units of code work as expected
  • Integration testing, which verifies how different modules or services within an application work together
  • Regression testing, which is performed after a bug is fixed to ensure that specific bug won’t occur again

CICD-pipeline.webp

CI/CD Fundamentals

There are eight fundamental elements of CI/CD that help ensure maximum efficiency for your development lifecycle. These elements span development and deployment. By including these fundamentals in your pipeline, you can improve your DevOps workflow and software delivery:

  1. A single source repository

    Source code management (SCM) is critical for housing all necessary files and scripts to create builds. The repository should contain everything needed for the build, including source code, database structure, libraries, properties files, and version control. It should also contain test scripts and scripts to build applications.

  2. Frequent check-ins to the main branch

    Integrate code in your trunk, mainline, or master branch – i.e., trunk-based development – early and often. Avoid sub-branches and work with the main branch only. Use small segments of code and merge them into the branch as frequently as possible. Don’t merge more than one change at a time.

  3. Automated builds

    Scripts should include everything you need to build from a single command. This includes web server files, database scripts, and application software. The CI processes should automatically package and compile the code into a usable application.

  4. Self-testing builds

    CI/CD requires continuous testing. Testing scripts should ensure that the failure of a test results in a failed build. Use static pre-build testing scripts to check code for integrity, quality, and security compliance. Only allow code that passes static tests into the build.

  5. Frequent iterations

    Multiple commits to the repository results in fewer places for conflicts to hide. Make small, frequent iterations rather than major changes. By doing this, it’s possible to roll changes back easily if there’s a problem or conflict.

  6. Stable testing environments

    Code should be tested in a cloned version of the production environment. You can’t test new code in the live production version. Create a cloned environment that’s as close as possible to the real environment. Use rigorous testing scripts to detect and identify bugs that slipped through the initial pre-build testing process.

  7. Maximum visibility

    Every developer should be able to access the latest executables and see any changes made to the repository. Information in the repository should be visible to all. Use version control to manage handoffs so developers know which is the latest version. Maximum visibility means everyone can monitor progress and identify potential concerns.

  8. Predictable deployments anytime

    Deployments should be so routine and low-risk that the team is comfortable doing them anytime. CI/CD testing and verification processes should be rigorous and reliable, giving the team confidence to deploy updates at any time. Frequent deployments incorporating limited changes also pose lower risks and can be easily rolled back.

The Benefits of CI/CD Implementation

Companies and organizations that adopt CI/CD tend to notice a lot of positive changes. Here are some of the benefits you can look forward to as you implement CI/CD:

  • Happier users and customers: Fewer bugs and errors make it into production, so your users and customers have a better experience. This leads to improved levels of customer satisfaction, improved customer confidence, and a better reputation for your organization.
  • Accelerated time-to-value: When you can deploy any time, you can bring products and new features to market faster. Your development costs are lower, and a faster turnaround frees your team for other work. Customers get results faster, giving your company a competitive edge.
  • Less firefighting: Testing code more often, in smaller batches, and earlier in the development cycle can seriously cut down on fire drills. This results in a smoother development cycle and less team stress. Results are more predictable, and it’s easier to find and fix bugs.
  • Hit dates more reliably: Removing deployment bottlenecks and making deployments predictable can remove a lot of the uncertainty around hitting key dates. Breaking work into smaller, manageable bites means it’s easier to complete each stage on time and track progress. This approach gives plenty of time to monitor overall progress and determine completion dates more accurately.
  • Free up developers’ time: With more of the deployment process automated, the team has time for more rewarding projects. It’s estimated that developers spend between 35% and 50% of their time testing, validating, and debugging code. By automating these processes, developers significantly improve their productivity.
  • Less context switching: Getting real-time feedback on their code makes it easier for developers to work on one thing at a time and minimizes their cognitive load. By working with small sections of code that are automatically tested, developers can debug code quickly while their minds are still fresh from programming. Finding bugs is easier because there’s less code to review.
  • Reduce burnout: Research shows that CD measurably reduces deployment pain and team burnout. Developers experience less frustration and strain when working with CI/CD processes. This leads to happier and healthier employees and less burnout.
  • Recover faster: CI/CD makes it easier to fix issues and recover from incidents, reducing mean time to resolution (MTTR). Continuous deployment practices mean frequent small software updates so when bugs appear, it’s easier to pin them down. Developers have the option of fixing bugs quickly or rolling back the change so that the customer can get back to work quickly.

Reference

  • https://www.redhat.com/en/topics/devops/what-is-ci-cd
  • https://about.gitlab.com/topics/ci-cd/
Leave a message