What is "pipeline as code", and why is it better than configuring pipelines in a UI?
BeginnerConceptCI/CD practices
Answer
In one line: Pipeline as code means defining your CI/CD pipeline in a file stored in the same Git repository as the app — such as a Jenkinsfile, .github/workflows/*.yml or .gitlab-ci.yml — instead of clicking through settings in a web UI.
Examples of pipeline-as-code files:
| Tool | File |
|---|---|
| Jenkins | Jenkinsfile |
| GitHub Actions | .github/workflows/ci.yml |
| GitLab CI | .gitlab-ci.yml |
| Azure Pipelines | azure-pipelines.yml |
| CircleCI | .circleci/config.yml |
Why it's better:
- Version control — every pipeline change has history: who changed it, when and why.
- Code review — pipeline changes go through pull requests like app code.
- Easy rollback — if a pipeline change breaks builds, revert the commit.
- Branch-specific pipelines — a feature branch can change its pipeline without affecting main.
- Reusable — share templates or shared libraries across many repos.
- Disaster recovery — if the CI server dies, the pipelines aren't lost; they're in Git.
- Self-documenting — anyone can read how the app is built and deployed.
Problems with UI-configured pipelines:
- Nobody knows who changed a setting or why.
- Hard to copy to new projects without mistakes.
- Lost if the server is rebuilt without a backup.
- Each project slowly becomes different ("snowflake pipelines").
Example:
# .github/workflows/ci.yml
name: ci
on: [pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make test
Tip for interviews: mention reusable templates (Jenkins shared libraries, GitHub reusable workflows, GitLab include) — at scale, that's how teams keep dozens of pipelines consistent.
More on CI/CD practices
What is a build agent or runner?BeginnerWhat are pipeline triggers?BeginnerWhat is a quality gate in a CI/CD pipeline?BeginnerHow do you make a slow CI/CD pipeline faster?BeginnerWhat are secrets in CI/CD, and how should they be handled?BeginnerWhat is a monorepo vs a polyrepo, and how does it affect CI/CD?Beginner