What is continuous integration? 

Authors

Chrystal R. China

Staff Writer, Automation & ITOps

IBM Think

Michael Goodwin

Staff Editor, Automation & ITOps

IBM Think

Continuous integration defined

Continuous integration (CI) is a software development practice in which developers regularly integrate new code and code changes into a central code repository throughout the development cycle. It is a key component of DevOps and agile methodologies. 

Continuous integration is the first part of the CI/CD pipeline, an automated DevOps workflow that streamlines the software delivery process. Continuous integration enables DevOps teams to continuously improve their software applications, receive consistent feedback, catch and fix errors before they affect software performance, and deliver higher-quality software on more predictable delivery schedules. 

How continuous integration works: A quick summary

When a developer commits code changes to a main or shared branch of a version control system, the action triggers a CI tool to perform a “build” of the updated code base. The CI system grabs the new code, compiles it with existing code and packages it with any dependencies, such as configuration files, libraries or other resources. This constitutes “the build.”

Automated tests are run to validate this build before a "build artifact"—the resulting file that is passed along for further testing or to a production environment—is produced. This next part of the pipeline is referred to as continuous delivery.

Why is continuous integration important?

CI was created as a solution to the challenges associated with traditional software development, namely its integration and deployment processes. In traditional development paradigms, each developer is responsible for manually integrating new code into new iterations of an app or service, making integration a time-consuming, error-prone process, especially for large development teams.

Different pieces of code didn’t always work well together, and developers integrated their changes on different timelines (sometimes at the last minute), so feedback on integration issues was often delayed. When issues arose, feedback delays made it harder for teams to figure out which change introduced the issue and made debugging a more arduous process.

Furthermore, software testing was infrequent. Teams typically implemented large batch updates all at once, which allowed bugs to slip through the cracks and accumulate in the code base. As a result, development teams encountered more challenging troubleshooting tasks, higher failure rates and slower code releases; businesses lost revenue to process inefficiencies; and users saw more software errors and glitches.

Continuous integration—a foundational component of modern DevOps practices, continuous integration/continuous deployment (CI/CD) pipelines and microservices architectures— helps streamline the build process by providing rapid feedback on integration performance.

With a CI system, new code is added to a central repository (typically, multiple times a day), where it remains for building and testing. If the system detects an error, it sends out notifications, corrects the code and confirms that the updated code is correct before fully merging it with the software’s code base.

The latest tech news, backed by expert insights

Stay up to date on the most important—and intriguing—industry trends on AI, automation, data and beyond with the Think newsletter. See the IBM Privacy Statement.

Thank you! You are subscribed.

Your subscription will be delivered in English. You will find an unsubscribe link in every newsletter. You can manage your subscriptions or unsubscribe here. Refer to our IBM Privacy Statement for more information.

Key CI components and processes

While the exact configuration of a continuous integration system varies from team to team and business to business, every CI system uses certain components and processes to optimize code integration tasks.

Central source code repositories

CI starts with a central, shared repository where all developers commit their code. Central repositories serve as the cornerstone of CI practices. Version control systems (VCSs) such as Git and Bitbucket often manage these repositories. When developers submit changes, the central repository tracks them, creating a complete history of code changes that development teams can use to collaborate more efficiently.

Repositories also use branching techniques, which create separate lines of development to isolate in-progress code changes from the main codebase (the main branch) and facilitate parallel development. Branching enables developers to build feature branches (for isolating specific app features) and short-lived branches to separate their work before merging it back into the main code branch.

Gitflow, for example, is a Git-based branching model that assigns roles (such as “main,” “feature,” “develop” and “release”) to different branches to govern how they interact with each other. Gitflow branches require developers to create feature branches and wait until the feature is complete to merge code changes into the main branch.

Continuous integration servers

CI servers are tools that centralize and manage all CI operations. They serve as the automation hub of the CI process. CI servers monitor repositories for code changes and initiate and power predefined CI pipelines when changes are detected. CI servers run automated builds, tests and software releases; orchestrate version control protocols; handle status reporting; and support plug-ins that can enhance system functionality.

Many CI servers feature user interfaces that help teams model and visualize workflows and construct their continuous delivery (CD) pipelines.

Code integration

CI systems encourage developers to submit code changes several times daily, prioritizing small, focused changes to specific tasks or features. CI tools enable teams to initiate code reviews and discuss issues before merging new code so that errors are caught earlier in the development process.

A Git-based CI system can, for example, initiate pull requests to fetch code changes from a local branch (stored locally on a single developer’s computer) and integrate them into the current remote branch (stored remotely and shared by the entire development team). And merge requests enable developers to integrate proposed changes from a local branch with another local branch for team review, discussion and approval before merging them with the remote branch.

Build automation

Continuous integration servers and tools (including popular open source tools such as Jenkins, CircleCI, GitHub, AWS CodePipeline and GitLab CI) monitor the central repository for code changes. When they detect a new change, CI servers trigger the build process and execute predefined workflows and build scripts, compiling and packaging the code in preparation for testing and ultimately, deployment.

Automated testing

CI tools run a range of tests to validate code before it merges with the code base. Unit tests validate individual components or functions, providing immediate feedback on code behavior. Integration tests assess interactions between software components and modules to make sure they’re working together correctly and to catch any issues unit tests might miss.

In some CI workflows, end-to-end testing validates software by simulating user interactions to verify that the software behaves correctly from the user’s perspective. Teams can also run code quality tests and static analyses to check the application’s responsiveness and stability under load and to identify coding standard violations and security vulnerabilities.

Feedback mechanisms and artifact management

CI servers notify developers immediately if a build or test fails. When there is a failure, developers can prioritize repairing the code to help ensure the main branch remains deployable.

If a software build is successful, the servers produce artifacts—files, such as compiled code, Docker images and libraries, created during the build process—that are versioned and stored in repositories for future testing and deployment. Regardless of the result, leading CI systems log integration attempts, success rates and other metrics to make sure team members can always access comprehensive version documentation.

IBM DevOps

What is DevOps?

Andrea Crawford explains what DevOps is, the value of DevOps, and how DevOps practices and tools help you move your apps through the entire software delivery pipeline from ideation through production. Led by top IBM thought leaders, the curriculum is designed to help business leaders gain the knowledge needed to prioritize the AI investments that can drive growth.

The importance of testing code in CI

Testing is a vital component of continuous integration processes. At a minimum, testing constitutes about a third of CI activities, but that’s only true when teams run a single test stage. Often, testing activities make up most of the workload for CI tools. 

Continuous testing in a CI environment begins when a developer commits new code to a code base. This action triggers a build and an automated testing process. In many cases, additional testing is performed once a build artifact has been created (before the code goes into production). It’s also important that developers run tests—and subsets of tests—in their local environment to help ensure that they only commit source code to version control after the new code changes pass their tests.

This multifaceted testing of various functions, use cases and integrations is collectively referred to as the test suite. This approach maximizes test coverage, prevents code regression and lays the groundwork for successful continuous delivery.

Test-driven development (TDD) is another approach to software development. TDD is an approach where developers “work backwards,” writing a test before writing any code. In this approach, developers write a unit-level test case that fails, before writing the minimum amount of code to make it pass. Once this is done, both the test and production code can be refactored and improved.

This approach helps developers focus on well-defined requirements and avoid extraneous code. It also emphasizes continuous feedback and can be a successful technique for accelerating development cycles.

Continuous integration in DevOps

DevOps pipelines accelerate the delivery of high-quality software by automating and combining the efforts of development and IT operations teams, which traditionally existed in their own silos.

Successful DevOps processes and cultures extend beyond development and operations to include platform and infrastructure engineering, security, compliance, governance, risk management, line-of-business, end users and customers. In other words, good DevOps should incorporate input from all application stakeholders into the software development lifecycle.

In a DevOps framework, continuous integration sits at the beginning of the software development process and the CI/CD pipeline. CI enables developers to frequently check their code to prevent local copies from drifting too far away from the main branch of the code build. This approach helps teams avoid merge conflicts that might "break" the build in the delivery and deployment phases.

CI also enables developers to submit small, frequent updates that promote quick, consistent feedback loops and continuous improvement based on the prioritization of customer needs—key tenets of the DevOps philosophy.

CI vs. continuous delivery and continuous deployment

Continuous integration is the first stop in the CI/CD pipeline and is typically followed by continuous delivery and continuous deployment processes. Continuous integration refers to the frequent code merges and the builds and unit tests that follow.

Continuous delivery (CD) picks up where continuous integration leaves off, automating the delivery of validated code base changes (including updates, bug fixes and even new features) into select environments or code repositories. DevOps teams receive notifications about the latest build, and can manually move the updates into a live production environment. The goal of the continuous delivery pipeline stage is to deploy new code with minimal effort but still allow a level of human oversight before code goes live.

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 help ensure code integrity. Both continuous delivery and continuous deployment deal with automating further down the pipeline than CI and are often used interchangeably.

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, such as assessing risks and identifying source-code vulnerabilities. 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—human approval is unnecessary.1

Continuous integration and agile development

Agile development is an iterative approach to software engineering that prioritizes flexibility, collaboration, continuous improvement and rapid adaptation to change. It’s a practice that organizes development into smaller groups of work—or “sprints”—to streamline collaboration between developers and stakeholders and accelerate software delivery.

Similarly, CI requires frequent, incremental code updates and continuous code validation. It’s an iterative approach to development that enables developers to quickly upgrade and scale software solutions over time and to deliver high-quality products to users faster. As such, continuous integration is an inherently agile practice. 

Continuous integration strategies

Continuous integration helps development teams iterate faster and deliver better software to users, but there are additional steps a business can take to optimize the process. Commonly implemented CI practices include:

Maintaining a single source code repository

A consolidated, centralized code base can simplify distribution and visibility. Many organizations use source control management to maintain a single repository that tracks and controls all the files associated with a product build.

Using daily mainline commits

Organizations can create a culture of consistency by requiring developers to commit their changes to the main development stream at least once a day to verify that their working copy is in alignment.

Maintaining a fast, efficient build process

Optimizing build scripts, parallelizing tasks and using caching mechanisms can reduce build times. Teams can also configure CI pipelines so that new integrations are vetted early in the iteration process. This proactive approach enables developers to address problems quickly and spend less time debugging.

Testing in a clone of the production environment

Creating a test environment that is as similar as possible to the final production environment can help ensure that test results provide an accurate representation of how software will perform in the real world.

Relying on feature flags

Implementing feature flags to control the release of new features enables CI systems to merge incomplete or experimental features into the main branch without affecting overall production.

Reviewing the CI pipeline often

Frequently reviewing and updating the CI pipeline to incorporate new tools, technologies and best practices helps DevOps teams strengthen the pipeline and update development practices as project needs evolve.

Implementing test-driven development

With TDD, tests are written before any feature code is implemented. Development and product teams collaborate to outline product specifications, the requirements are transformed into a checklist of code assertions, and developers write code that satisfies the tests. A TDD approach enables teams to proactively integrate high-quality, reliable code changes into CI pipelines.

Trends in continuous integration

Continuous integration practices—and DevOps frameworks more broadly—help businesses streamline collaboration and code integration and maintain continuous delivery pipelines. Such practices improve software quality and accelerate software release processes. Modern CI tools incorporate a range of emerging technologies that strengthen these practices and enhance their value.

For instance, the use of artificial intelligence (AI) and machine learning (ML) in continuous integration processes is becoming standard development practice. AI-enabled tools can help developers create self-healing systems that automatically and autonomously identify and correct problematic code before it affects the main development stream. ML-driven CI systems can also autogenerate tailored test cases based on code submissions and modifications, so developers spend less time manually creating code tests.

With cyberthreats growing more sophisticated,2 developers are increasingly weaving security practices directly into the software development process. These “shift-left” security strategies introduce security checks into the earliest phases of development—including CI processes—to help ensure that vulnerabilities are caught during coding rather than after deployment.

Today, Kubernetes and the broader ecosystem of container-related technologies form the building blocks of modern IT environments. DevSecOps integrates security into every phase of DevOps to address the security challenges that accompany such dynamic ecosystems.

Containers are executable units of software that package application code along with its libraries and dependencies so that the code can run in any computing environment. And Kubernetes—also known as k8s or kube—is an open source container orchestration platform for scheduling and automating the deployment, management and scaling of containerized applications.

Traditionally, DevOps teams relied on a separate security team to identify vulnerabilities and then used the feedback to implement code changes in the next round of app updates. Now, developers are expected to secure containers and Kubernetes clusters and apply zero-trust principles throughout their software applications and the development process, which reflects a new operating paradigm.3 The adoption of DevSecOps practices mean that coding and software development are no longer just about building features, but also about anticipating risks.

Serverless computing and cloud-native architectures are also a priority for today’s DevOps teams.

Serverless computing is an app development and execution model that enables developers to build and run application code without provisioning or managing servers or backend infrastructure. The servers in a serverless setup do exist, but they’re managed entirely by a cloud service provider (CSP). In CI pipelines, serverless platforms free developers from backend infrastructure concerns, so they can focus on front-end coding and business logic.

With the proliferation of serverless computing and AI applications, event-driven architectures (EDAs) play a central role in helping teams tackle the increasing complexity of cloud computing. EDAs support real-time communication between loosely coupled front-end and backend systems, enabling systems to work independently and process events (any change or action that occurs within a system) asynchronously.

In CI pipelines that means developers can scale individual app components without affecting the entire application, which helps teams create more agile, responsive, scalable codebases and integration processes.

Benefits of continuous integration

Setting up a robust CI pipeline requires careful planning and configuration, including choosing the right tools, defining build and test workflows, and configuring infrastructure. CI pipelines also require regular maintenance to accommodate changes to the code base, dependencies (such as APIs) and infrastructure.

However, implementing CI can offer software development teams an array of benefits, including:

Earlier, more efficient error detection

CI processes enable teams to address errors early—sometimes within minutes of code submission.

Improved team collaboration

Everyone on the team can change code, merge code changes, and identify code incompatibilities and integration errors, simplifying knowledge sharing and improving code and software quality through peer feedback.

Accelerated software development

Because new code is integrated continuously, teams spend less time integrating and testing large batches of code. And the accelerated feedback loop CI tools offer helps developers iterate and deliver software updates and new products to end users faster.

Reduced risk in the development process

Frequent code commits mean smaller, more incremental changes that are easier to understand, review and test. This reduces the risk of introducing significant issues into the code base during development. 

Related solutions
IBM HashiCorp

Optimize your cloud with unified lifecycle automation - secure, scalable hybrid infrastructure designed for resilience and AI.

Explore IBM HashiCorp
DevOps solutions

Use DevOps software and tools to build, deploy and manage cloud-native apps across multiple devices and environments.

Explore DevOps solutions
Cloud consulting services

Transform your business with end-to-end cloud strategy, migration and modernization - built for hybrid, AI-infused environments and business agility. 

Explore cloud consulting services
Take the next step

From unified lifecycle automation with HashiCorp to enterprise-grade DevOps tools, you can secure, deploy, and manage resilient cloud-native applications across any environment.

Discover IBM HashiCorp Explore DevOps solutions