https://www.techtarget.com/searchitoperations/tip/How-to-build-a-CI-CD-pipeline-with-examples
Developers deliver value by writing software that solves a problem. Software development and delivery traverse various stages and steps until they reach the customers, and this delivery chain must be fast, safe and reliable.
These are the principles that govern continuous integration and continuous delivery or deployment. An effective continuous integration/continuous delivery (CI/CD) pipeline integrates automation tools and workflows an organization needs to build, compile, test and release its applications. Automate as many of these steps as possible to minimize manual effort and errors, and enhance the feedback loops throughout the software development lifecycle. Teams deliver smaller chunks of better-quality code releases in less time.
Every organization will set up a CI/CD pipeline differently based on its internal processes, resources and infrastructure. The specific components and tools in any CI/CD pipeline example depend on the team's particular needs and existing workflow. However, at a high level CI/CD pipelines tend to have a common composition.
A CI/CD pipeline resembles the various stages software goes through in its lifecycle and mimics those stages:
Let's lay out the steps that occur in each stage that collectively create a CI/CD pipeline, with pointers to specific CI/CD pipeline examples.
This initial CI/CD stage involves storing and managing source code in a repository with a version control system (VCS) that supports collaboration and tracking changes across a distributed team. The VCS can trigger a pipeline execution based on various events, such as a branch push or pull request validation. These pipeline runs also can be scheduled or initiated by a user.
The key to this CI/CD stage is to provide early feedback to developers and maintain the application in a state where it can be released to an environment.
It is imperative to provide feedback as soon as a developer checks in new code changes to flag and resolve any issues such as syntax or compilation. Also, compilation ensures that the code can successfully generate artifacts for eventual release into environments further down the CI/CD pipeline.
The goal of this stage is to ensure that the changes do not break any logic or functionality and that the code is safe to release. In short, testing provides a safety net to release the code. Among the many tests that occur in this stage are unit, integration and functional tests.
Unit tests examine small units of application code and only test the logic in isolation without any dependencies, although if required, you can simulate them through mocking. For code developed in object-oriented languages such as Java or C#, etc., these small units can be class methods.
Integration tests analyze individual units of code together in a group. This builds confidence that individual modules integrated to build the entire application won't break under test.
An end-to-end functional test introduces the software into an environment to mimic a production deployment. This step is often automated with tools such as Selenium.
Once the software is built and tested and artifacts are generated, it is ready to be released into an environment. Ideally, there are multiple environments through which the built artifacts are released and then tested, and if the release passes all the tests it progresses through to production deployment. This stage also handles adding the required resources to host the application in the cloud.
There are no ironclad rules that define the best ways to create CI/CD pipelines. However, there are certain guidelines to follow while building these pipelines.
CI/CD pipelines aim to streamline software development and delivery, but real-world implementations can widely differ from the theoretical concepts. Organizations have specific problems to tackle, resources to draw upon and technology decisions to weigh.
Consider investments in time and resources to manage the infrastructure that supports CI/CD pipelines. On-premises repos and version control such as Git, along with build servers such as Jenkins, require a lot of effort to patch and maintain.
If a team chooses to run the CI/CD pipelines with hosted providers, such as GitHub and Azure DevOps, there are additional considerations. A CI/CD pipeline in the cloud typically deploys the application as a hosted workload on that cloud's platform and will require the team to assign underlying infrastructure resources (IaaS, PaaS or SaaS).
There are also many security questions to answer with CI/CD in the cloud. How do you authenticate users and grant them appropriate access to resources? How does the provider store credentials or service connection strings to access outside resources? How do CI/CD pipelines with a cloud provider access internal resources if required? Many providers allow organizations to run the hosted agent in their internal network, but this requires outbound connections to allow egress traffic, which may require a security review and exception.
There is no one-size-fits-all answer to implementing a CI/CD pipeline. However, there are common attributes and CI/CD best practices that can help you design, implement and continuously improve your software delivery process. Start with very basic pipelines and then continuously gather feedback and improve them over time.
19 May 2021