CI/CD automation (Part I)
What is CI?
Continuous integration (CI) is a DevOps software development practice where developers regularly merge their changes into a central repository, for automated integration and test case executions. CI is a development practice that requires developers to integrate code into a repository several times a day. By integrating regularly, developers can detect errors quickly, and locate them more easily.
CI saves cost of development. Lack of CI usage increases the time between two integrations which exponentially increases the difficulties in finding and fixing the problems. Such integration problems can be easily knock-off a project off its schedule, or may lead to a project failure.
A key principle of a Continuous Delivery approach is that the application is always production ready. This implies that all artifacts required to build the application are stored and managed in a version control system, and that code must be regularly merged with the source mainline to ensure small increments between builds.
There are three important and fundamental elements that underpin any Continuous Integration System.
1. Commitment to building tests: The commitment of the development team to produce a comprehensive test suite at the unit level and functional level together with their code is the most important element of a CI system. This element is essential to achieve the “guaranteed” level of code quality that can be production ready at any moment.
2. Never break the build: The goal is that the application must be ready to be built, packaged and deployed on every committed change.
3. Version Control: Another fundamental element to Continuous Integration is version control. To be ready to focus on implementing Continuous Integration, the code needs to be managed by strict version control policies
There are many languages developer can choose from, different test suites, countless frameworks and many CI offerings. CI is a way to increase code quality without putting an extra burden on the developers. Tests and code checks are handled on a CI server. In case of any error, it is automatically reported back to developers.
Here are some of the reasons why any organization should implement CI in their project,
1. Allow developers to run their tests in the real world:
When a developer writes a code, the tests are successfully passed on his/her machine but the same fails on someone else’s. CI can save such ambiguities. Developer just have to push their code to the new branch and CI server will take care of running test
2. Improve Developer productivity:
Continuous integration helps teams to be more productive by freeing developers from manual tasks that help to reduce the number of errors and bugs released to customers.
3. Find and Address Bugs Quicker:
With more frequent testing, Team can discover and address bugs earlier before they grow into larger problems later.
4. Deliver Updates Faster:
CI helps team to deliver updates to their customers faster and more frequently
5. Increases trust in the software quality:
By continually building the software, increases confidence that the software is of high quality
CI is most essential element during the build or integration stage of the software release.
The key goals of continuous integration are
- To find and address errands quicker
- Improve software quality
- Reduce the validation and release time for new software updates
What is CD?
Continuous delivery (CD) is a DevOps software development practice where the integrated changes are automatically built, tested, and prepared for a release to production. CD is the ability to get changes of all types including new features, configuration changes, bug fixes and experiments into production, or into the hands of users, safely and quickly in a sustainable way. When continuous delivery is implemented correctly, developers will always have a deployment-ready build artifact that has passed through a standardized test process.
Principles of CD
1. Automate Everything
A manual deployment can never be described as repeatable and reliable. Company has to invest seriously in automating all the tasks that they do repeatedly, and this tends to lead to reliability.
2. Everybody has responsibility for the release process
Developers should develop projects with a mind for how to deploy them. Project managers should plan projects with attention to deployment. Testers should test for deployment defects with as much care and attention as they do for code defects.
3. Improve continuously
Continuous improvement means system will always be evolving and therefore easier to change when needs be.
1.Low risk releases:
The primary goal of continuous delivery is to make software deployments painless, low-risk events that can be performed at any time, on demand.
2. Higher quality:
When developers have automated tools that discover regressions within minutes, teams are freed to focus their effort on user research and higher level testing activities such as exploratory testing, usability testing, and performance and security testing.
3. Lower costs:
Any successful software product or service will evolve significantly over the course of its lifetime. By investing in build, test, deployment and environment automation, an organization can substantially reduce the cost of making and delivering incremental changes to the software by eliminating many of the fixed costs associated with the release process.
4. Better products.
Continuous delivery makes it economic to work in small batches.
Goals of CD
- Automate the Software Release Process
- Improve Developer Productivity
- Deliver Updates Faster
“The CI/CD Pipeline”
CD/CI pipeline is an important aspect of a software project. It saves a lot of manual and error-prone deployment work. It results in higher quality software after continuous integration, automated tests, and code metrics.
With a CI/CD pipeline, for every change in software code, it is built and tested automatically. Code analysis are executed against it. If it passes quality control gates along with the required tests, it is automatically deployed. The automated acceptance tests are executed against it. This process of quality control and automation is getting more and more necessary in today’s fast-paced software-centric environment where companies have to release stable versions of software frequently.
CI/CD pipeline consists following steps:
- Commit: When a developer finishes a change to an application, he or she commits it to a central source code repository
- Build: The change is checked out from the repository and the software is built so that it can be run by a computer.
- Automated tests: The change is tested from multiple angles to ensure it works and that it doesn’t break anything in the system/software
- Deploy: The built version is deployed to production
Benefits of the CI/CD Pipeline
1. Developers have greater control over the process and can respond more quickly to market demands by quickly bringing up new environments, testing against them and easily starting over, if required. Moreover, developers can quickly adjust to new environments — an approach that has proven to decrease failures and resolution time when they do occur
2. Operations benefits as reduced friction in the CI/CD pipeline created by automation decreases repetitive and manual work along with the opportunity for “fat finger” mistakes thus improving efficiency of the process
3. Less manual and repetitive work provides everyone in the process with more time for strategic work, which provides direct bottom-line value to the organization
The greatest benefit of CI/CD automation is reduced risk. Many a times the issues with delayed and infrequent integration manifest during the on-going process of project development, where the stakes are high and pressure to deliver is greatest. Further, it provides easy way for automation at many levels, starting with build automation, test automation and more recently continuous delivery, all of which aim to encourage the creation of higher quality software, faster.
In the next post, we will show an example of how to set up CI/CD automation using Jenkins….