This article discusses continuous integration (CI) and continuous delivery/deployment (CD), which are part and parcel of the DevOps software development culture. The goal of all developers is to produce software that is reliable, reusable, extendable, flexible, correct and efficient. DevOps ensures this, with CI and CD as integral parts of the process.
In simple terms, integrate when you commit. Continuous integration implementation doesn’t mean less bugs. Rather, it highlights the issues or bugs in the early stages and hence is useful because the earlier in the development cycle you fail, the faster you recover!
The benefits of detecting bugs early
In the case of discovering failures or bugs, it becomes the priority of the respective stakeholders to focus on solving build or continuous integration issues at the earliest and fix the broken build.
Continuous integration (CI) is a popular DevOps practice that requires the development team to commit code into a shared repository (Centralised Version Control or Distributed Version Control) as and when a feature is completed or a bug is fixed. Each commit goes through a build validation process using an automated build process with any automation tool feasible, based on the knowledge or the culture of the organisation.
It is important for the development team to commit frequently whenever a feature is implemented or a bug is fixed. There are still some developers who commit code even if it is not properly tested or is not working fine. There are also instances when code is committed even if the compilation fails; or when libraries are hard coded and the path in the developer’s system is different, and hence the compilation fails.
The solution
Please don’t commit if you are not ready. This piece of advice holds good for life as well as while developing software! After each commit, build validation has to pass, all quality gates have to be cleared and things must work successfully in the pipeline.
Even if the pipeline fails, it must be fixed immediately. This failure helps the Jenkins engineer and developer to grow.
Failure should be the motive to inspire us to continue to fix problems and improve continuously even if a temporary failure creates a road block. We must not avoid build failures but address them head on. Build success is only one step away when the issues are fixed.
When you decide to go down the path of cultural transformation, think about the satisfaction you’ll get when after addressing multiple failures, your software eventually gets the green status.
Benefits, best practices and challenges of CI
We can understand some of the benefits of continuous integration from Figure 2.
Best practices make it easy to implement continuous integration within an organisation, without resistance. Please refer to Figure 3.
The major challenge with continuous integration is the mindset! People resist it because all developers are so used to the IDE, its features and functionality that any new tool is not welcomed. It is important to start with the proof-of-concept and a demo of all the automation activities orchestrated in the automation server. This helps to develop a mindset that is ready to accept new practices.
Once the resistance is overcome, the development team can use CI practices effectively because it helps to boost productivity.
Continuous delivery
Continuous delivery and continuous deployment are the next logical steps when implementing DevOps practices.
Continuous integration creates an artifact that needs to be deployed in a development or QA stage, or a production environment. The next step is automated deployment in different environments. These environments can be on-premise or on the cloud. Resources can be physical or virtual machines, or containers. Services can be Infrastructure as a Service or a Platform as a Service, where the artifact can be deployed.
The continuous delivery phase represents activities to deploy an artifact in non-production environments using scripts or deployment tools. The artifact is always ready to be deployed in production. Usually, continuous delivery is a preferred practice since there’s less risk involved with it.
The continuous deployment phase represents activities to deploy the artifact in production environments using scripts or deployment tools. The artifact is directly deployed in production. Usually, continuous delivery is preferred to continuous deployment.
Benefits, best practices and challenges of continuous delivery
Success and failure are both equally important during digital and cultural transformation activities. Let’s understand some of the benefits of continuous delivery from Figure 5.
The best practices that make it easy to implement continuous delivery are shown in Figure 6.
A major challenge with continuous integration is gaining control over the environment and people’s mindset.
The dev environment might be in control of the development team, yet there are specific instances when this is not the case. VDI (virtual desktop infrastructure) is given to developers to create code for an application or different components of an application. Most of the time, environments are controlled by customers and they are not willing to relinquish this due to security reasons; hence, automated deployment to all the environments might not be feasible all the time.
Cloud resources and containers are changing the game. The way cloud services are used for infrastructure as well as for the DevOps setup helps to automate deployment in different environments.