Continuous Integration and Delivery in an Agile Environment
Continuous integration and continuous delivery (CI/CD) are modern development best practices that have changed the way developers create software. Learn how to use CI/CD in your own development process and save both time and money in the long run
What are continuous integration and continuous delivery?
CI/CD are software development and DevOps best practices.
“CI” stands for continuous integration, while “CD” can mean either continuous delivery or continuous deployment.
Continuous integration is not merely a technology or a methodology; it’s a whole culture that has a set of rules, principles, and practices for fast and reliable software development. The implementation of this culture into a development process is called the CI/CD pipeline.
It’s not easy to implement CI/CD into the project, because it requires lots of resources on writing the automated tests. However, in the long run it accelerates the development process and helps our clients to get a more high-quality code that’s easy to test and maintain
Yulia Kutsokon, project manager at Mobindustry
CI/CD is perfect for Agile development, as it focuses on flexibility, code quality, and constant testing. The purpose of continuous integration is to save time on future maintenance and testing, as the code is tested each time it’s merged, which often happens every day or even several times a day. It integrates perfectly with the lean startup principles, as well as best practices of any Agile software development.
What is continuous integration model and what is continuous delivery? These two methodologies often go hand in hand, but let’s define these terms separately first for better understanding. Then, we’ll discuss how to implement continuous delivery into your project.
Continuous integration (CI) is a philosophy, a set of rules, and a DevOps best practice, and it is used during the whole development process. According to CI, developers create software piece by piece and merge the code to a single repository where it’s tested. Then the build is created automatically. If tests don’t pass, the code simply isn’t merged, and this allows developers to avoid integration issues.
Modern software development requires compatibility with lots of platforms, screen sizes, and tools, so software should be constantly updated and changed. Once the waterfall approach to development became outdated for fast-moving startups and ever-changing markets, developers required an algorithm that would allow them to build, package, and assure the quality of their applications.
The main continuous integration purpose is creating a clear pipeline for producing and building code. Continuous integration works as a consistent algorithm that prevents the development process from being messy and unclear. It also encourages collaboration, as developers can create separate pieces of code for different features and merge the code at the end of the day.
Continuous delivery is an extension of continuous integration. Continuous delivery automates the process of delivering code to certain infrastructure and development environments defined at the beginning of development.
Most development teams have not only a production environment but also development and testing environments. Continuous delivery helps to bring app changes to all those environments.
As I already mentioned, CD can also stand for continuous deployment. This advanced practice allows developers to deploy their app changes directly to the production environment after they run through the CI/CD pipeline.
In simple words, continuous integration is a part of continuous delivery and continuous deployment. Both continuous delivery and continuous deployment help to bring application changes to the development environment, and the main difference is that continuous deployment releases them automatically.
Both CI and CD create a unified environment for the constant building, merging, testing, and deploying of code according to rules of specific environments. They perform all calls to web services, databases, and other services to deploy applications correctly.
Testing is also one of the most important things CI/CD software does. Continuous testing is performed regularly and automatically. Regular testing allows developers to improve code quality because instead of testing the whole app after development, CI/CD suggests gradual and constant testing of small parts of code.
This allows developers to find bugs fast because they know exactly where they’re located. During each merge, the CI/CD system also checks the code as a whole to see if previously developed parts interact correctly with each other and the new code.
Benefits of CI/CD in software development
Now that you have a better understanding of what CI/CD is, let’s talk about what both these practices bring to the table when you implement them into your development routine.
Thanks to automated tests run on each new part of code before merging, the number of bugs in your software can be drastically reduced. Code quality is one of the most important benefits of CI/CD, as it allows you to find bugs early before adding code to the main branch.
Because all integration issues are solved fast right before merging, you get to build your releases fast. Previously, developers merged code and dealt with all issues and bugs later, after a large amount of code was already developed. This resulted in lengthy testing processes and situations where you fixed a bug in one place and it broke the system in another place.
More time to focus on further development and quality control
Both developers and quality assurance specialists save lots of time with CI/CD. Developers don’t need to spend days on preparing the next release, giving them time to work on other features. Quality assurance costs also go down because most tests are automated, and a CI server can run thousands of tests simultaneously.
CI/CD makes it so easy to change code and try new things that the pressure of making small decisions is lifted, leaving lots of space for iterations. This is especially useful for Agile development, which focuses on constant experimentation. Traditional development approaches can’t offer the flexibility to experiment without the risk of breaking something in the existing code.
Now you know about the benefits of continuous integration and continuous delivery in your development process. However, to reap these benefits, you need to set up the pipeline correctly, and this means not only using the right continuous integration tools but also creating a new culture of code development in your company. Let’s talk about how to do CI/CD right, step by step.
How to do CI/CD right in your development process
Continuous integration and continuous delivery is a set of rules and principles that you need to integrate into your everyday development pipeline. Here are the things you need to do in order for CI/CD to work to your benefit.
Write automated tests
Automated testing is one of the most important principles of CI/CD. Your developers should write automated tests for each new feature, bug fix, or improvement with the help of automated testing frameworks. These automated tests will determine whether a certain build passes and can be merged into the main branch without any issues.
All tests for functionality should be aggregated into a regression test for the entire app after every sprint, in each developer’s local environment. Thus, a developer will be able to commit code to version control only after it passes regression testing.
Note that you can also automate other kinds of testing like security testing, API testing, performance testing, and static code analysis. After tests are automated, they can be integrated into your continuous integration pipeline.
Set up a CI server
A continuous integration server monitors the main repository and can run thousands of tests automatically when each committed piece of code is pushed.
A CI server is also called a build server, and it initiates a build each time new code comes in and documents whether it’s successful.
For CI/CD to be successful, developers need to merge code as often as possible to find issues early and accelerate the development process. According to CI best practices, merging should happen at least once a day.
Develop a build schedule
The frequency of initiating builds depends on the team size, expected daily commits, and business demands. You need to discuss the build schedule with your team beforehand and take all factors into account.
CI/CD suggests fast commits and builds, so the team is motivated to code and commit frequently and do as many iterations as possible.
Deployments should also be automated. Though they can still be triggered manually according to continuous delivery, the human intervention stops there, and the deployment process happens automatically.
Use feature flags
A feature flag is a CI configuration mechanism that allows developers to switch both code and separate features on or off during runtime. Feature flags wrap features that are still being developed. Developers can deploy those features to production and turn them off until they’re ready for use. Thus, you can deploy new features to the production environment and give access to certain users while hiding them from other users.
For example, you can give internal users access to new features so they can test them or give feedback, but these features won’t be available for your external users. Essentially, feature flags are used to make changes to the main branch without having to maintain multiple branches within your source code.
Optimizely Rollouts, LaunchDarkly, and CloudBees Rollout are some of the most popular feature flagging tools on the market.
Use version control branching
Version control branching is another popular strategy that defines how new code is merged into branches for testing, development, and production. Developers also often add additional branches for features that will take longer to develop, test, and deploy.
After all changes have been made and features are ready for deployment, they are merged into a primary branch. The main challenge of version control is managing all branches and features that are being developed simultaneously.
Continuous delivery and deployment best practices
Now let’s talk about what a continuous delivery and deployment process looks like. Continuous deployment is the process of pushing apps to delivery environments. This process can be initiated either automatically or manually.
Continuous deployment is an extension of continuous integration, and its pipeline consists of three main stages: build, test, and deploy. However, depending on the product and your specific technical needs, you can expand this pipeline with additional steps. Here’s a list of all possible steps for continuous deployment:
- Creating a build after pulling code from version control
- Automating required infrastructure steps
- Moving code to the target environment
- Changing variables according to the target environment
- Pushing app components to web, API, and database services
- Calling service endpoints for new code pushes
- Performing tests and rolling back environments until the build passes
- Setting up delivery status alerts and notifications
All these steps can be taken through special continuous integration and continuous deployment tools like Jenkins, Azure DevOps, Kubernetes, Travis CI, Atlassian Bamboo, and CircleCI. They not only help with automation but also provide regular reports on builds and delivery.
In Jenkins, such a report is called a Jenkinsfile, and it contains a description of all stages, variables, keys, certificates, and other parameters for every stage and build. You can also see data about errors and delivery states in a Jenkinsfile.
Advanced continuous delivery tools also offer data synchronization, library patching, and data resource archiving. All these features can be accessed through plugins. As you can see, it’s important to choose the right set of tools for your CI/CD pipeline so that you get a clear algorithm of testing and creating builds and also oversee the whole continuous integration and delivery process through analytics and reporting.
In the next section, you’ll find out about the most popular CI/CD tools on the market.
Top CI/CD tools
When choosing a CI/CD tool, make sure it has all the features you’ll need for your project alongside integrations with other software like version control systems and Agile tools. The continuous delivery and continuous integration software mentioned in this article are the top in the industry right now, and they have necessary functionality and plugins that expand their abilities.
Git is one of the most popular DevOps tools in the world that every developer knows about. Git is a source code management (SCM) tool that’s perfect for code collaboration, as it helps you track changes in any set of files. Git is great for both small and large projects. It supports distributed and non-linear workflows, which is perfect for Agile development. To manage Git repositories in the cloud, you need to use Github.
Jenkins is probably the most popular tool that most developers use for automating delivery stages. Jenkins offers an open-source CI/CD server that allows developers to run automated tests and automatically create and deploy builds.
Originally, Jenkins was used only for continuous integration, but now it’s a fully fledged CI/CD tool that works with all languages and platforms including Linux, macOS, and Windows.
Docker is a container-based engine that allows developers to deliver software in isolated packages called containers. Each container has its own software, libraries, and configuration files. And while they’re separate, they still communicate with each other through different channels.
Developers use Docker to run multiple environments and separate their applications from the infrastructure. This allows them to deliver software fast and also be able to manage infrastructure the same as applications.
CircleCI is a popular alternative to Jenkins. It’s also a continuous integration and continuous deployment server that allows developers to work as a team and collaborate on building, testing, and deploying applications.
Jenkins is considered more secure than CircleCI, but CircleCI is more open and simpler, so it’s perfect for smaller projects.
Unlike other tools I’ve mentioned, Bamboo is a commercial CI/CD server, not an open-source one. It comes with lots of built-in features, unlike other platforms that use plugins for expanding their functionality.
Bamboo has a dedicated team of developers and offers a clean and simple interface as well as great technical support and documentation.
As you can see, there are lots of options when it comes to tools. At Mobindustry, we use Git for version control and Jenkins for building, testing, and deploying our apps. These are two of the most secure and popular solutions on the market.
Just like Agile development, continuous integration and continuous delivery have become a standard for development processes in recent years. Both of these methodologies allow developers to quickly release flexible, reliable applications that are versatile, meaning changes can be implemented almost immediately.
CI/CD has disrupted the way developers create software and provided businesses with limitless opportunities for experimentation.
If you want to learn more about how to organize your software development process or you wonder how development goes at our company, don’t hesitate to contact us. Our developers will help you choose the right set of tools and the right CI/CD pipeline according to your specific business and technical needs.