What is continuous integration?
Continuous integration (CI) is a popular term used in the software engineering or Agile ecosystem. It is basically an engineering practice whereby a developer merges his or her working piece of code with other developers' work into the shared mainline/branch multiple times a day. Grady Booch, an American software engineer, first coined the term and proposed CI in 1991. Eventually, extreme programming (XP) adopted the concept of CI and advocated to integrate it more than once per day.
Benefits of CI
- CI is a quality control practice. By following CI, we avoid integration problems that arise when we merge late in the development life cycle or when we merge big changes at once.
- CI avoids the problem of integration hell (a scenario in which the time taken to resolve conflicts that arise when big chunks of code changes are merged at the last minute is greater than the time required to make those changes).
- CI avoids the last-minute chaos when all developers are trying to check in their slightly incompatible versions of code.
- Debugging becomes easier. Because we integrate smaller changes more frequently, it is easier to know which version of code change caused a failure, and it is easier to revert to the previous state without losing many changes.
- CI pushes developers to create less complex, more modular code.
What is continuous delivery?
Continuous delivery (CD) is made possible with continuous deployment. CD is about making sure that the smallest code change has the ability to move through all the processes or environments, such as system integration testing or user acceptance testing, through the staging environments, and is finally deployed confidently into production without any issues (e.g., bug, performance, or any other errors).
Difference between CI and continuous deployment
Continuous deployment is the ability to deploy to production multiple times in a day (companies like HP, Flickr, and Facebook do it). CD is broader in scope, and the business decides when to deploy to production. As mentioned, CD is made possible with the ability to continually deploy.
By deploying multiple times a day, the business wants to avoid the risk of a high degree of churn and changes to production. Hence, although CD can deploy to production, you might choose not to and instead set a production deployment frequency — for example, every two weeks or monthly.
Benefits of CD
The benefits of continuous delivery are many:
- CD lowers risk. Because CD follows configuration management and CI, if anything breaks or goes wrong after the latest deployment, then it becomes relatively easier to track what went wrong — we would look at less code and maybe even roll back to a previous version. By following CI, we are integrating smaller changes more frequently, and therefore the risk factor is lower. Consequently, rollbacks to previous working versions are simpler.
- Enables user feedback. Because CD is all about the ability to go live and getting customers to use the product, we can secure more real-time feedback, which eventually leads to greater learning.
- CD gives a sense of real progress. Rather than looking at the burn-down charts, lead time, and cycle times whereby we track sprint progress or development team members who are finishing their jobs, CD really tells how much has actually gone live to production. This instills greater confidence. Even if we are not going live (we are really closer to live), it is better than a developer saying, "I am done with my job."
How to achieve continuous delivery
- Solid configuration management: This is nothing but version control. Ensure that you have a strong system for version control for source code, database schemas, deployment scripts, and everything necessary to configure servers and testing environments so that if anything goes wrong into production, we can quickly determine which version caused it and take necessary action.
- DevOps culture: Ensure that there exists a culture of collaboration and teamwork between developers and operations teams to smoothen the deployment process. Establish a culture wherein these groups help each other and a culture of automation, which is the heart of communication.
- Continuous integration: Establish the practice whereby every developer integrates with other developers' work frequently. Also, strive for a matured state that even integrating multiple times there exists a solid battery of tests to give the confidence of not leaking any defects to production. However, if that happened, the production failure during this process can be fixed within 15–20 minutes. That’s a true sense of continuous integration.