By: IBM Cloud Education

In this guide, learn more about continuous integration, a software development and DevOps practice where each developer integrates their work with the main branch of code at least once a day.

What is continuous integration?

Continuous integration is a software development process where developers integrate their code more frequently—at least once a day—in order to identify integration issues earlier, when they are easier to fix. Overall, continuous integration helps you reduce your code development effort, resulting in higher-quality software and more predictable delivery schedules.

For a deeper dive, see Eric Minick's video, "What is Continuous Integration?":

Continuous integration (CI) and continuous delivery (CD)

Continuous integration (CI) is a DevOps practice where each developer integrates their work with the main branch of code at least once a day (or, preferably, multiple times a day). Continuous delivery (CD), on the other hand, is another DevOps practice that focuses on delivering any validated changes to code—updates, bug fixes, even new features—to users as quickly and safely as possible.

Continuous delivery picks up where continuous integration ends, automating the delivery of applications to selected infrastructure environments. It ensures automated pushing of code changes to different environments, such as development, testing, and production.

The following video explains more about continuous delivery:

Benefits

The following are a few of the most notable benefits that continuous integration provides:

  • Continuous and demonstrated progress for improved feedback
  • Early and improved error detection that lets you address errors early—sometimes within minutes of check-in
  • Improved team collaboration so they know they can change the code, integrate the system, and quickly determine conflicts with other parts of the software
  • Improved system integration that reduces surprises at the end of the software development lifecycle
  • Fewer parallel changes for merging and testing
  • Reduced number of errors during system testing
  • Constantly updated systems to test against

CI, Agile, and DevOps

Agile

Agile is a software development methodology that improves how work teams organize themselves, adapt to changes in requirements, and release software. Because continuous integration and agile development share many many of the same features (e.g., automated testing), you may find it useful to talk about continuous integration and agile at the same time. Agile organizes development into smaller groups of work or sprints. When applied in DevOps, these combined practices provide both high quality development and project flexibility.

Continuous integration requires you to integrate work frequently, which leads to multiple integrations each day. You verify integration by an automated build that detects integration errors as early as possible. The build should include tests as part of verification. Extending the rapid testing to runtime tests in a test environment leads naturally towards continuous delivery. Agile is also iterative and adapts to change so it can scale and evolve solutions over time. It’s about software iterations based on how you prioritize the value of the features as you continuously integrate.

DevOps

In the DevOps framework, continuous integration sits at the beginning of the software development process, where you check in your code at least once a day (or more) to keep your local copies from drifting too far away from the main branch of the code build. This helps you avoid disastrous merge conflicts that could "break" the build and take the team hours or days to resolve.

Continuous integration serves as a prerequisite for the testing, deploy, and releases stages of continuous delivery. The entire development team will know within minutes of check-in whether you've created bad code, as the continuous integration service automatically builds and tests your code changes for any errors.

Andrea Crawford provides more background on DevOps in the following video:

Tools

The following are some of the most popular continuous integration tools:

  • Jenkins: A widely used open source continuous integration tool, Jenkins allows developers to automatically build, integrate, and test code as soon as they commit it to the source repository, making it easier for developers to catch bugs early and deploy software faster.
  • BuildBot: BuildBot can automate all aspects of the software development cycle. As a job scheduling system, it queues jobs, executes jobs, and reports results.
  • Go: What makes Go stand out from the crowd is the concept of pipelines, which makes the modeling of complex build workflows easy.
  • IBM UrbanCode Build: Optimized for large organizations, IBM UrbanCode Build has a strong enterprise angle. If you have a small team trying to deliver continuous integration to many application groups, take a look.
  • Travis CI: One of the oldest and most-trusted hosted solutions, it is also available in an on-premises version for the enterprise.
  • TeamCity: TeamCity works on many different platforms, has support for a wide variety of tools and frameworks, and boasts many publicly available plugins. Despite being Java-based, TeamCity offers the best .NET support.
  • GitLab CI: An integral part of the open source Rails project, GitLab CI is a free hosted service that provides detailed git repository management, with features like access control, issue tracking, code reviews, and more.
  • CircleCI: CircleCI distinguishes itself in the way its services are priced—by “container.” One container is free, and you can build as many projects on it as you need.

Open source tools

Conducting continuous integration with open source tools offers many benefits, including the following:

  • Hundreds of plugins that can support your project
  • Wide support for open source languages, such as Python, Java, and JavaScript
  • No cost, giving students, startups, and developers working on the side a powerful tool that's easy on the budget
  • Customizability, allowing developers to take the foundation of a CI tool and build on top of it to fit the needs
  • The ability to modify and redistribute the tools

Open source continuous integration tools to consider for your software development workflow include Jenkins, Go, BuildBot, and Travis CI, which you can read about in the next section.

Use case

The following hypothetical use case illustrates how two software developers use continuous integration to improve their DevOps process.

The two developers must communicate who works on what features and how. This small team needs regular updates and must be able to integrate and test their code as a whole. Scheduling code check-in and testing takes up a lot of development time. An automatic system for continuous integration is needed.

Negotiating when these combinations and tests would happen would eat up a lot of developer time. To do that they must agree on the following:

  1. When to begin testing code integration.
  2. Testing that the integration has been successful.
  3. How to communicate the results to the team.

Continuous integration platforms have default answers to these questions, and most allow configuration and setup.

Typically, CI platforms like Jenkins begin integration tests on check-in. When code is checked in, the CI system will run a set of tests and then determine if the code was successfully integrated.

Or, if you're using a compiled language, the default test will be if the code compiles successfully. If not, then one of the developers broke the build. For languages like Python or JavaScript, you must create your own integration test.

Either way, most CI systems log the integration attempts, success rate, etc.

Servers

A continuous integration server is a software tool that centralizes all your continuous integration (CI) operations and provides a reliable, stable platform for you to build your projects. You can configure and adjust CI servers to build various projects for different platforms. A continuous integration server easily models and visualizes complex workflows (enabling continuous delivery) and provides an intuitive interface for building continuous delivery pipelines. A continuous integration server offers the following benefits:

  • Run automatic builds, tests, and releases in a single place
  • Deploy any version, anytime
  • Keep configuration orderly
  • Support plugins to enhance functionality
  • Monitor your project’s repository
  • Pull changes and perform tasks you defined for successful commit
  • Send feedback to the relevant project members with details of the build

The importance of testing

Continuous testing begins when you produce a continuous integration build and a package (also known as an installable entity or packaged entity). It stops when that packaged entity goes into production. Every step from end-to-end involves testing.

At a minimum, when you only have one test stage, 30% of continuous integration involves testing. In reality, continuous integration activities are comprised of 50% to 70% testing. It used to be that you had to complete testing manually. Now you can automate testing—the key to successful continuous integration.

As part of automating continuous integration testing, test-driven development iteratively builds code and tests one use case at a time to ensure test coverage, improve code quality, and set the groundwork for continuous delivery. Testing tells you whether a code change failed one or more of the tests developed across all functional areas of the application. A best practice requires developers to run all or a subset of tests in their local environments, which ensures that developers only commit code to version control after code changes pass their tests.

Continuous integration pipeline

A continuous integration pipeline automates stages of a project's pipeline—such as builds, tests, and deployments—in a repeatable way, with minimal human intervention. A continuous integration pipeline is essential to streamline the development, testing, and deployment of your applications by enabling controls, checkpoints, and speed.

Best practices

The continuous integration process is a critical component of DevOps, which helps you unify your development and operations teams into a cohesive unit for coding, testing, deploying, and supporting software. The following are some CI best practices that can help you succeed:

  • Maintain a single source repository: Use source control management to track and control all the files for building a product. This makes distribution and visibility easier.
  • Automate the build: This involves compiling, linking, and other processes that produce the build artifacts. Self-testing should also be automated.
  • Use daily mainline commits: Force developers to commit their changes to the main development stream at least once every day. Each developer must verify that their working copy is consistent with the main development stream
  • Test in a clone of the production environment: Make the test environment as similar as possible to your final production environment.
  • Automate deployment: Implement multiple environments (development, integration, production) to run builds and tests.

Continuous integration and IBM Cloud

The effort required to integrate a system increases exponentially with time. By integrating the system more frequently, you identify integration issues earlier, when you can fix them more easily, thereby reducing your overall integration effort. The result is a higher-quality product and more predictable delivery schedules.

If your team doesn't know continuous integration, start small, and then add practices. For example, start with a daily integration build and add tests and automated inspections (such as code coverage) to the build process. As the team begins to adopt the practices, increase the build frequency.

Explore IBM UrbanCode Build, a continuous integration and build management server optimized for the enterprise.

Sign up for an IBMid and create your IBM Cloud account.

Follow IBM Cloud

IBM Cloud News connects you to insight and information you can put to work right away—straight from the minds of IBM Cloud experts, IBM customers, and business and IT leaders.

Email subscribeRSS

Be the first to hear about news, product updates, and innovation from IBM Cloud