It used to take hours, weeks even, to ship software – but now companies are doing it in a matter of minutes.
What was once a struggle to make ends meet is now a simple and speedy job, thanks to CI/CD. You must be asking, “what is ci/cd?” but don’t worry, we are going to explain it all.
Today, you can expect a detailed description along with some simple concepts to hit the ground running.
Continuous Integration – Explained
The “CI” part of CI/CD stands for Continuous Integration. CI is the process of taking code from build, to testing, to an artifact ready for deployment. “Continuous” refers to the fact that builds can be created and ready to deploy multiple times per day.
It works like this – the developers work on code and push this code into the master branch.
The build server then processes this change and builds the application as instructed. Before it turns the build into an artifact, it runs tests to make sure everything is okay, and reports back if it finds an error.
People used to wait until the release stage before they started testing. This meant changing more than just one element of the code as multiple developers had interacted with it and added their own information. This caused the process to take a longer time than needed.
Using a CI tool, you stop that future from happening. Instead, errors are found at this early stage, and you can change them before they become a mess.
CI tools, such as Jenkins, Drone, Concourse CI, Travis CI, CircleCI, and more, can help you automate the process easily. Each tool has its own pros and cons, so do research on each tool you are considering. Your use case might fit a tool better than another. For example, a small company may do fine with an open-source tool, while a large organization may need a tool with enterprise-grade features.
Committing To Master
The biggest change when moving to a CI system is committing to master. Technically it is an easy function, as it’s like hitting “save” on a game. But in reality, this concept contains a cultural shift.
People who’ve been working in the industry for decades will have a hard time changing their ways. Usually, they would finish their code and push it into the relevant feature branch, but we need a mini-save before the tree gets too large.
There is a concept called Trunk Based Development that explains this reasoning well. If you are interested, we recommend giving it a read. But to keep it simple, we need the developers to push the code into the master branch.
This is because the master or main branch will always be there. If the feature branch is ever removed or no longer needed, the code will be lost when it’s gone. Put the code in the master branch, and it’s saved.
Trusting The Automated Tests
Doing so many tests every day means you need to have a reliable system. It needs to flag up any issues that might appear. You can put in as many different tests you think are necessary, but a great automated system will decide what tests to run for you. Not all CI tools offer this kind of functionality, so most likely, you’ll be choosing which tests to run.
For example, if you compile code, the very first test you should be considering is, “Does the code compile?” That might seem simple, but fixing this type of error now will stop it from being a head-scratcher later on.
Most importantly, whatever the tests tell you, you should believe it is true. There is no point in using a testing system that isn’t reliable. As a human being, it is normal for you to make mistakes, but your software shouldn’t have the same faults.
Fixing Bugs Is A Priority
This is another culture change for a lot of seasoned developers. Once upon a time, the idea was to deploy a set of features and then go back to fix the bugs. This still happens on occasion, as tests won’t catch literally everything, but ideally tests cover a large enough portion of code that bugs caught after a deployment are the minority. Most bugs should be caught in the testing phase of CI. Producing a bug-free artifact should be the priority.
The Right Tools For CI
We have briefly touched on tools earlier but wanted to give you a little more information to help you start your research. Because CI is mostly a cultural shift, it doesn’t take long to get into the process. As James Shore says, all you need is an old computer, a desk bell, and a rubber chicken!
That being said, tools can be extremely useful to get you started. Here is a handful you can choose from with a little description added in.
- Azure Pipelines – This is a Microsoft product that uses open-source projects. You can start it for free and can include no more than 5 users.
- Cloud Build – This service is created by Google through their Google Cloud Platform.
- Circle CI – This tool works seamlessly with GitHub projects. It is a self-hosted project which you can use for free.
- CodeShip – This tool only uses self-hosted solutions. It is a paid-for service, but there is a free version you can try.
- GitLab CI – As you can expect, GitLab CI works extremely well with GitLab, but it can also be used alongside other tools too.
- Jenkins – Jenkins is another free tool that uses open-source solutions. However, it is Java-based, which means you’d have a lot of flexibility.
Continuous Delivery – Explained
The “CD” part of CI/CD stands for Continuous Delivery. It describes the ability to install changes into production (ie: what customers see). These changes could be new features, bug fixes, anything. The changes are delivered seamlessly and to a live environment.
The idea behind Continuous Delivery is in the name: making frequent deployments (usually multiple per day) that are smaller in size, as opposed to a monthly release cycle (for example) that are huge and take a long time to complete.
CD itself isn’t an environment; it is simply another stage to your pipeline.
Focus On Small And Frequent Deployments
Whenever you deploy, your application’s stability is a concern. There is a possibility that, if you’re doing a large deployment where multiple people contributed code, there could be a bug (or multiple!) that will break the entire deployment and result in a rollback that could potentially take hours.
Think of it this way: the old way of doing things (two-week sprints, monthly release cycles, etc) pose a huge risk of downtime, while Continuous Delivery ensures smaller deployments, often multiple times a day, where if an error does happen, it’s easy to undo.
If you’ve been using Continuous Integration and properly testing your code, then there shouldn’t be a lot of bugs to deal with, but if any come up, you only have a handful of changes to consider/roll back.
As far as tools go, try to go with an actual CD tool. Tools like Jenkins and CircleCI can be extended to perform CD as well, but that requires a lot of scripting work upfront, and then in maintaining the system. A true CD tool, like GoCD, Argo CD, Harness, and Octopus Deploy, is built correctly with deployment in mind.
Better yet, if you’re going to do CI/CD, get a CI/CD tool! Platforms like Harness, Azure DevOps, Codefresh, and more have the right idea in mind by combining both for a unified pipeline. It’s easier to learn one platform than two separate tools.
Don’t worry; we aren’t about to jump into a sci-fi movie. The idea of labor automation is to automate anything that a person would typically do through physicality; however, anything that contains a person’s mind should be manual.
For example, it takes a person to create a recipe, but following one can lead to mistakes. You could miss a line and forget the sugar, or you could stop paying attention and over-whisk the eggs. These are simple human errors that would never happen with a machine. Creating the recipe is different, though. It would take trial and error, imagination, and the understanding of flavors.
We can bring this metaphor into the world of software engineering. Doing repetitive tasks can easily lead to lower concentration, so try to automate these tasks. But anything that requires intellectual thought, creative problem solving, or multiple perspectives should be left in the hands of your developers.
The Right Tools For CD
We have touched on tools a little bit but want to expand. You may notice that many CD tools are also CI tools, so some of the options we give you may be repeated. If you want to hit two birds with one stone, then opting for these joint-use tools could be the best option.
- Harness – Harness is a developer-first experience that uses CI, CD, Feature Flags, and more.
- Azure Pipelines – Azure has the ability to integrate a definition section into your build stage.
- GitLab CI – This tool is a great choice if you already use GitLab as it allows you to work seamlessly without conflict errors.
- Jenkins – Jenkins uses plugins like Terraform and Ansible to use the CD pipeline as code.
- Spinnaker – Spinnaker is relatively new compared to these other tools; however, it is quickly becoming popular due to one massive client – Netflix. Netflix uses Spinnaker to create releases.
Give Yourself Room To Improve
Improving at anything doesn’t happen overnight. If you try to do too many things too fast, you will become overwhelmed. An overwhelmed mind backs out of the stressful situation and might not get back on track for a long time. The same goes for your systems and your developers.
When you are happy with how things are going, then it’s time to improve.
CI/CD doesn’t just make it easier to fix bugs and deploy artifacts. It also eases the struggles between developers and DevOps. True collaboration and communication can begin when CI/CD is done right.
This, in turn, allows both teams to focus on improving the business and delivering value to their customers.
So there you have it, the basic concept of CI/CD. Following our outlines, you will be able to create a happy environment for your workers, quick and reliable content for your customers, and easy to manage pipelines to fix bugs!