Pipeline as code is a practice of defining deployment pipelines through source code, such as Git. Pipeline as code is part of a larger “as code” movement that includes infrastructure as code. Teams can configure builds, tests, and deployment in code that is trackable and stored in a centralized source repository. Teams can use a declarative YAML approach or a vendor-specific programming language, such as Jenkins and Groovy, but the premise remains the same.
A pipeline as code file specifies the stages, jobs, and actions for a pipeline to perform. Because the file is versioned, changes in pipeline code can be tested in branches with the corresponding application release.
The pipeline as code model of creating continuous integration pipelines is an industry best practice, but deployment pipelines used to be created very differently.
Early in continuous integration, deployment pipelines were set up as point-and-click or through a graphical user interface (GUI). This presented several challenges:
The pipeline as code model corrected many of these pain points and offered the flexibility teams needed to execute efficiently.
Pipeline as code comes with many of the same benefits the other "as code" models have, such as:
Pipeline as code also has operational and practical benefits:
CI pipelines and application code are stored in the same source repository. All the information teams need is located in the same place.
Developers can make changes without additional permissions and can work in the tools they’re already using.
Teams can collaborate more efficiently. Keeping information accessible means teams can collaborate and then act on their decisions.
Pipeline changes go through a code review process, avoiding any break in the pipeline integration.
Deployment pipelines are in a version control system independent of continuous integration tools. Pipelines can be restored if the continuous integration system goes down. If a team wants to switch CI tools later on, pipelines can be moved into a new system.
The pipeline as code model creates automated processes that help developers build applications more efficiently. Having everything documented in a source repository allows for greater visibility and collaboration so that everyone can continually improve processes.