Pipeline-as-Code

Pipeline definitions versioned in the repo. GitHub Actions, GitLab CI, Jenkinsfile — and how to keep them DRY at scale.

Overview

What pipeline-as-code is

Pipeline-as-code means the build, test and deploy pipeline is defined as version-controlled source code in the same repository as the application, not as a click-configured job in a CI server's UI.

The life of a pipeline change shows the idea. The repo holds the app code and the pipeline file side by side. A change to the pipeline arrives as a pull request and is reviewed like any other change. Once merged, the CI server reads the file and interprets it, and the file drives the build, test and deploy.

Each major CI tool reads its own file, and the idea spread over about eight years.

  • Travis CI (2011): .travis.yml.
  • GitLab CI (2015): .gitlab-ci.yml.
  • Jenkins 2.0 (2016): the Jenkinsfile. This is the release that popularized the shift.
  • CircleCI: .circleci/config.yml.
  • GitHub Actions (2019): .github/workflows/*.yml.

Key concepts

  • Pipeline-as-code
  • Declarative pipeline
  • Scripted pipeline
  • Reusable workflow / composite action
  • Self-hosted runner
  • SHA pinning for actions

Interview questions

  • Why is pipeline-as-code strictly better than UI-configured jobs?
  • GitHub Actions vs Jenkins vs GitLab CI — when do you pick which?
  • How do you keep pipelines DRY across 30 microservices without creating a single point of failure?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio