Continuous Integration, Delivery & Deployment
Continuous integration (CI), Continuous Delivery (CD) and Continuous Deployment (CD) embody a culture, set of operating principles, and collection of practices that enable application development teams to deliver and deploy code changes more frequently and reliably. The implementation is also known as the CI/CD/CD pipeline.
CI/CD/CD is one of the best practices for DevOps teams to implement. It is also an Agile methodology best practice, as it enables software development teams to focus on meeting business requirements, code quality, and security because deployment steps are automated.
While not every project is destined to achieve great success, there are software methodologies and practices that can dramatically increase the chance of success of a project, and make the development process a more rewarding experience. Implemeting the CI/CD/CD pipeline , along with creating a DevOps culture and using Agile Methodologies, teams are more and more delivering on this promise. CI/CD/CD pipeline has become an immensely popular practice that is now considered indepsensible to most teams developing software.
The initial use of the CI process was the Jenkins project, which was started in 2004 (originally called Hudson) by Kohsuke Kawaguchi, while he worked for Sun Microsystems. Kohsuke was a developer at Sun and did not want to be criticized any more by his team every time his code broke the build. He created Jenkins as a way to perform continuous integration, to test his code before he did an actual commit to the repository. Once his teammates saw what he was doing, they all wanted to use Jenkins. Kohsuke open sourced it, creating the Jenkins project, and soon Jenkins usage had spread around the world.
The complete CI/CD/CD process was originally adopted as an Extreme Programming (XP) practice, and its main purpose was to prevent integration problems and to avoid “integration hell”.
Developers can best utilize the CI/CD/CD process by leveraging on Open Source tooling (e.g., Jenkins, GIT, and Bamboo from Atalassian), or using cloud based services (e.g., AWS Code Deploy), that automate various integration, deployment, and release management tasks.
CI is important because if a build is integrated and it fails, the development team knows exactly at which iteration the bad code is in. CI is also important because it helps you to obtain faster results and faster feedback which is the key element of Agile way of working.
Specifically, CI/CD introduces ongoing automation and continuous monitoring throughout the lifecycle of apps, from integration and testing phases to delivery and deployment.
Continuous integration (CI) is the practice of automating the integration of code changes from multiple contributors into a single software project. The CI process is comprised of automatic tools that assert the new code's correctness before integration.
Definitions of the processes within the pipeline practice:
Continuous integration focuses on integrating work from individual developers into a main repository multiple times a day to catch integration bugs early and accelerate collaborative development.
Continuous delivery is concerned with reducing friction in the deployment or release process, automating the steps required to deploy a build so that code can be released safely at any time.
Continuous deployment takes this one step further by automatically deploying each time a code change is made.
Who benefits from the implementation of a CI/CD/CD pipeline?
The biggest difference between the stages of the CI/CD/CD pipeline is whom it benefits most at each stage.
Continuous Integration benefits developers most because it allows for code produced to be automatically tested and continuously “integrated” with other developers’ code, and with the existing codebase. The developer benefits from receiving continuous and immediate feedback regarding code and integration errors. As s/he fixes these errors, automated testing tools in this stage will report if the errors were successfully fixed and when the code is accepted. This continuous feedback loop dramatically increases a developer’s productivity.
Continuous Delivery benefits business users because as soon as code is successfully accepted in the CI stage and a logical function can be tested, it is released to users. They verify that the features meet their expectations and provide feedback to developers who then address the feedback in this stage. This feedback loop between users and developers is continuous and seamless. Whereas in traditional waterfall method, users could wait weeks/months to see the features for the first time, this approach can dramatically reduce the time to just hours/days.
Continuous Deployment seamlessly pushes code that has been successfully accepted in the CI/CD cycle into the production environment. This stage benefits all key stakeholders, from application investors who fund the development to external consumers and internal end-users as new features/application is available for immediate (external) commercial sale or internal use. Developers can best utilize the CI/CD/CD process by leveraging on Open Source tooling (e.g., Jenkins, GIT, and Bamboo from Atalassian), or AWS services (e.g., Code Deploy) that automates various integration, deployment, and release management tasks.
Steps to implementing a successful Continuous Integration pipeline:
1. Run tests in a real world scenario
Avoid tests passing on one machine, and not another. Use CI to push code immediately to a new branch, so the CI server can run tests independently and automatically. If everything is green, developers can be reasonably confident that the test will not break anything.
2. Increase code coverage
A CI server checks code for test coverage, so every time a develper commits new code without any prior tests it is readily apparent that no tresting was done because their new code coverage percentage goes down because of their changes.
3. Automatically deploy code to production
The CI server can automatically deploy code to production if all the tests within a given branch are green. This is what is formally known as Continuous Deployment.
4. Compile code more often
If all tests are green and the coverage is good, then a CI server triggers the build and compilation processes . The CI server can be configured to automatically run this process, and generate a notification as soon as something goes wrong or the job is completed.
5. Build and test code faster
With parallel build support, tests and build processes can be split across different machines, or into a cloud environment, so it finishes faster. This will also free up development resources, so developers can continue working on something else while the builds run.
6. Avoid breaking code
Having code tested before and after it is merged allows developers to decrease the amount of times the master build is broken.
7. Decrease code review time
The CI and Version Control Servers communicate with each other and notify the developers when a merge request is good to merge. They can also show how the code coverage would be affected by it. This can dramatically reduce the time it takes to review a merge request.
Advantages and Disadvantags of the CI/CD/CD pipeline:
Software errors can be found and eliminated much more efficiently in the development process
There is less effort than with a classic software release. The developers can fully concentrate on the actual development
The continuous delivery pipeline makes it much easier for developers to troubleshoot problems.
There are fewer costs that would arise from other test processes (e.g. alpha and beta tests)
Quality assurance can devote more resources to the conceptual improvement than to the technical improvement of the software
Software development is generally faster, because the largely automated release process relieves developers of the workload and reduces the number of breaks they have to take
A strong and reliable integration server for the automated tests is necessary for a good and secure delivery of the product
The automated tests must be written and function perfectly. Faulty tests can cause great damage during quality testing
Requires good team coordination because code changes must be collected frequently and efficiently
Requires good and continuous communication with customers and their target systems
The customer expects continuous updates and improvements. The software project can rarely be "paused"
New features, improvements, and changes to the product are still delivered manually. To automate this process, you need to move to continuous deployment
The customer must show willingness to use software that is still in development. They must also be motivated to provide important feedback
Faster and more frequent releases accelerate the loop of feedback and improvement.
How can developers best utilize these methods?
In the most efficient situations, the CI/CD/CD pipeline is a fully automated (and sometimes autonomous) toolchain that ends in running software. This allows developers to focus on writing code and not on the minutia of build/test/deploy. Essentially, CI/CD/CD provides developers a reliable path to deliver and deploy their technology to users. Developers, and mostly DevOps teams, can benefit from tools that help them automate this pipeline to a point of autonomy so that any situation brought to the table (update, upgrade, downgrade, teardown, errors, rollback, etc.) can automatically be handled by the system without a team having to manage or script out the change.