Continuous integration and continuous delivery pipelines (CI/CD) are a must for any modern company that doesn't want to fall behind the competition. Software as well as infrastructure has become decentralized and complex over the course of the last few years. Software deployment is not done once a month anymore but, in some cases, multiple times per hour. Can you imagine manually deploying your software dozens of times a day? We can't either. That's why CI/CD pipelines are common these days. But it's not only necessary that drives the adoption of CI/CD pipelines. They provide unique advantages that in the long run help you deliver even faster and higher quality code. In this post, we'll talk about the second part of a CI/CD pipeline: continuous delivery. You'll learn what continuous delivery actually is and, more importantly, what benefits it has for your company.
What's CI, and What's CD, in CI/CD?
Before we dig into continuous delivery, we need to quickly refresh your knowledge about CI/CD pipelines in general. Continuous delivery comes at the end of the CI/CD, so it's good to understand what leads to it. Long story short, CI/CD is the automation of application development and deployment. A CI/CD pipeline consists of multiple steps that need to happen in order to automatically convert raw code to a working application. CI/CD pipelines are highly customizable and differ between companies. They're adjusted to a company's needs and the programming languages or frameworks used.
CI stands for continuous integration, and its job is to integrate the code written by multiple developers. What this means is that developers working on the same piece of code don't need to go to a room to discuss which code changes were done by whom and how to resolve conflicting changes. All of that can happen (semi)automatically in a continuous integration phase of a CI/CD pipeline. Once all these different changes are merged into one piece of code, it's time for continuous delivery.
As you probably know, the code itself doesn't do anything. That code needs to be compiled into a software binary or an artefact (for example, a Docker container). Sure, depending on the language used, it may be actually possible to "just run the code" (for example, HTML or even Python code can be simply executed on its own), but in a production environment, that's almost never the case. And while you could create such an artefact manually, that's a slow and unscalable way to deliver software. Instead, the continuous delivery part of a CI/CD pipeline can do it for you automatically every time new code changes are committed. You'll only need to initially configure your CI/CD pipeline and tell it how to build your code and where to publish it. So, what does it actually give you?
The Benefits of CD
Now that you know how CD fits into a CI/CD pipeline, let's talk about the benefits in more detail.
First and most obvious is the fact that you simply don't need to manually do it yourself. This means that you'll have more time to do the actual development. You won't need to waste your time waiting for the build to finish. That on its own would be a good reason to implement continuous delivery if you don't have it already. Manual software building, depending on your company specifics and the tools you use, could take up to half of your working hours. Imagine suddenly having that time back. You'd be able to deliver more features and fix more bugs in the same sprint.
It's also worth noting that the software building process can be frustrating. It's repetitive and sometimes slow. Developers want to solve software challenges; they want to write code. If you remove the frustrating and slow parts, you'll make them happier and directly contribute to increased productivity and creativity. Without continuous delivery, it's almost impossible.
When developers have more time, they're also more eager to experiment. And experimentation is good for any business. Even if your company is relatively steady and has been doing the same thing for years, experimenting can still bring you some benefits. The experiment doesn't need to mean changing your software entirely or building something new. You could, for example, decrease your software building or scanning time by changing the framework or libraries that you're using.
Continuous delivery, by definition, helps you build software faster. That bit of extra time saved by automated software delivery can mean a little more time to test a different way of building your software or changing your testing tools to finally run all tests in parallel instead of one at a time. With simple experiments like that, you can make drastic improvements to your software delivery processes.
Increased Code Quality
The time you'll save combined with the fact that every code change can be smaller enables you to naturally improve the quality of your code. Let's break it down. First of all, because you won't have to build the software yourself, you'll have more time to polish the code before committing it. But the bigger contributor to better code quality is smaller code changes. Before CI/CD, integrating and testing all the code changes was painful and slow. That forced most companies to do it less often and therefore to stash more changes to the code in one release. It's easier to vacuum the whole house once a week rather than every time you find some dirt on the floor.
With CI/CD, you don't have to do it this way. Since the software is integrated and built automatically, you can commit every small change. And smaller changes are easier to debug if something goes wrong. Imagine that you have hundreds of new features in your software, thousands of code lines changed in one release, and "something" goes wrong. Finding the problem could take hours or even days.
Compare that to having only one new feature in each commit. Finding an issue, in this case, should only take a couple of minutes. And over time you'll start seeing the patterns and common issues, something that's not easy to do when you're dealing with multiple issues at once with every release.
Another advantage of continuous delivery is the fact that once you have it, it's easy to add new pieces to it. Think about security scanning, for example, something that traditionally was done once in a while by a security team. Quite often, the results of such tests meant you had to rewrite half the code you'd spent weeks on.
But you can do it better and easier. Just add an additional step in your CI/CD pipeline for automated security scanning of every code change. Even if it won't find all possible vulnerabilities, it can drastically decrease their number. And just as with code quality in general, this automated security scanning as part of continuous delivery would, over time, allow you to see patterns and common security issues. And without too much effort or dedicated training, your developers would start writing more secure code.
How often do you test your rollback procedures? If something goes wrong with a new release, how many people in your company even know how to quickly deploy the previous version of your software? Rollback procedures are often complicated, and only a handful of people know them or even know where to find the instructions. With continuous delivery, you can automate the rollback procedure too.
Imagine that after a failed deployment, your software reverts to the previous version automatically without you even having to touch anything. That's easily achievable with a CI/CD pipeline. We mentioned previously that CD enables you to build better quality code, so failed deployment should be much rarer with CI/CD pipelines in place. But no testing is perfect, and there's always a chance that a bug will slip into the production environment. Therefore, the ability to quickly spot it and revert the deployment is priceless.
No one doubts that CI/CD is useful. Most companies have already implemented CI/CD into their software delivery lifecycle processes. Some benefits are automatic, such as faster time to market due. But more importantly, continuous delivery is full of possibilities. You can add any custom step to your pipeline that can help your organization specifically.