What is continuous integration?

Continuous integration (CI) is a practice within development wherein developers automate the integration of code into a single code repository.

Without CI, developers would have to manually coordinate and communicate their individual code contributions to the end product. A non-CI environment requires unnecessary bureaucracy and a complex synchronisation, which creates a situation that is more complex than it needs to be.

There is a likelihood of a communication breakdown between the engineering team and the rest of the organisation, particularly product and engineering. The time from development to product launch is largely unknown due to the time and complexity of integrating new changes that are not stored in a single repository or location.

Graphic showing the different factors of continuous integration.

CI, CD and continuous deployment are each crucial parts of the software release lifecycle, including DevOps processes.

Continuous integration (CI)

As a general rule, CI is used in conjunction with agile software development, which helps an organisation compile tasks into a list and product roadmap. Once outlined, the tasks are outlined to different team members for fulfilment. The several codes are then merged into a master code repository.

Continuous delivery (CD)

CD is the second part of the process. It involves the packaging of code together, which is then ready to be delivered to end users. This step of the process typically runs automated tools that generate an artifact, which makes it ready to deploy to end users at any time.

Continuous deployment

The final phase of the process, continuous deployment automatically launches the software product to end users, which means it has successfully passed integration and delivery. The automation utilises scripts or tools that transfer the software product to public servers or other means of public distribution. In a highly automated and well-governed environment these deployments happen automatically as soon as the product is delivered (hence continuous). Some teams or some products may instead be deployed at specific times or after other processes and checks have been completed.

Scaling

The minimisation of code bureaucracy can help DevOps and agile workflows work effectively and smoothly, from the development of new code through to the end of the cycle. CI can help a company scale when it removes dependencies that stand in the way of the development of individual features. Even though a developer works in a silo, they can do so knowing that their code will be integrated with the rest of the code repository.

Improve feedback loop

Business decisions receive faster feedback, which can help product teams test their ideas and better work with iterative product design. Changes can be rapid, measured and successful, and bugs can be quickly addressed and corrected.

Better communication

Engineering teams can better communicate and be held accountable, which allows for better communication in a DevOps team. Teams have the opportunity to view and comment on code written by other team members, which also provides the opportunity to collaborate on future code with other developers.

Version control

Code is run through version control software, such as Apache Subversion or Git, and the commit history of the software code is committed so that it can be changed if needed.

Build

Developers build out their code, and the code is passed through the version history system. The code is then returned to the build phase for compilation.

Testing and staging

Software undergoes testing, including the unit test that tests the units of software. The staging phase begins after successful testing, which means it is ready to be deployed into the staging process. Here, the code is viewed and finalised before the final testing phase.

Auto test

After the software has been in the staging environment, it undergoes automated tests that are prepared for the software. Once the software passes the automated tests, it is sent to the deployment phase.

Deployment

After the automated testing has occurred, the software is deployed to production. If there are any errors during the testing phase or subsequent deployment, the software returns to the version control procedure and is inspected for errors. If there are any errors identified, they are corrected.

Maintain a repository

Each artifact that is needed to build a project should be placed in a central code repository. This allows for integrated changes to be maintained rather than individual versions being maintained simultaneously.

Automate build

Ideally, there is a single command that is capable of building out a system—this includes automating integration, which deploys into a product-like environment. There are many cases where the script compiles binaries while generating web pages, distribution media, statistics and website pages.

Make the build self-testing

Each test should run in order to confirm that it is behaving in the way that it is expected to behave.

Everyone commits to the baseline

The chance of conflicting changes can be exponentially reduced when everyone is regularly committed. Daily buy-in helps developers identify any issues or necessary changes in the code, at which point they communicate the changes—a week’s worth of work piled up could further contribute to issues not being caught or becoming overwhelming, which is why daily commitment is necessary.

Every commit should be built

Commits need to be built to the current working version in order to verify they are working correctly. Automated Continuous Integration (ACI) is typically used, but it can also be done manually. ACI uses a daemon to watch the revision control system for any changes made, then it runs the build process automatically.

Keep builds fast

Each build should be completed as rapidly as possible to prevent any issues with integration, or quickly identify issues.

Clone the production environment for testing

A test environment can create failures in a tested system if they are deployed in a production environment—setting up a replica of the production environment can prevent failures, as a production environment may differ from a test environment. A separate staging environment must be a scalable version which maintains technology stack compositions, while alleviating costs.

Make it easy to get the latest deliverables

Stakeholders and testers may need to see the work, so it’s best to keep builds readily available in order to reduce the amount of necessary rework if a feature needs to be rebuilt. Early testing can also eliminate the possibility of errors carrying too far through the process.

Everyone on the team can see results

If a build breaks, it is usually easy to find. CI helps a team identify the changes that were made and the member of the team who made the changes, which can help with transparency and productivity.

Automate build deployment

Even after a build finishes, most CI systems will run scripts. It is possible to write a script in order to deploy the application to a live testing server that is available for everybody to see. CI calls for software to be deployed into production with additional automation to prevent any regressions or defects.

Test driven development

It is advisable to constantly develop and improve test coverage once a project has become established in the CI pipeline. There should be tests that accompany each new feature that makes its way down the CI pipeline to verify that the new code is functioning as expected.

Pull requests and code

Pull requests are a crucial part of CI—most software developers practice a pull request and code review process. A pull request is an excellent opportunity to start the CI pipeline in order to run through the steps of automated approval. Manual approval is also added at a pull request time, when a non-stakeholder can perform a review of code. This provides the opportunity for the non-stakeholder to identify edits, or approve or deny the pull request.

Optimise pipeline speed

It is crucial to optimise the execution speed of the CI pipeline, as it is a commonly used process. Delays in the workflow can compound issues during growing feature releases, codebase sizes and teams sizes. Constantly measure the CI pipeline to ensure it is optimised.

There is a faster CI feedback loop when there is a faster CI pipeline. Developers have the opportunity to push changes and experiment with a user experience, quickly fix bugs and increase execution speed for advantages over competition and all-around higher quality.

You can leverage CI/CD when building apps on the ServiceNow platform. You can also connect your CI/CD tools to ServiceNow’s DevOps product to link the work that is moving through the CI/CD pipeline to the work that is managed in ServiceNow. The ServiceNow DevOps product can provide many benefits to the CI/CD process whether you are building on the ServiceNow platform or outside of ServiceNow in tools like Azure DevOps, GitLab or Jenkins.

Collaborate better

Manage code changes effectively for multiple developers when using Git repo integration and make a connection between work items like user stories and the commits in the repo. With the additional connection of commits to test results and changes in ServiceNow you obtain a complete end-to-end view of the pipeline.

Streamline your DevOps

Automate change creation, approval and deployment and move from development, through testing and into production more quickly and efficiently.

Accelerate development

Deliver applications faster to help teams iterate faster on feedback both early and often.

Manage the value stream

Report on the entire pipeline or value stream from ideation to production. Communicate across teams, compare performance across disparate tools and identify and resolve bottlenecks.

Capabilities that expand with your business

Expand DevOps success across the enterprise. Take the risk out of going fast and minimise friction between IT operations and development.