Lesson 6 / 21
Pipeline as Code
Defining the pipeline itself in a versioned YAML file.
The idea
Pipeline-as-code means the build/test/deploy steps are written in a config file (usually YAML) that lives in the repo alongside the source code — not clicked together in a UI.
Shape of a pipeline file
Most pipeline-as-code files share this shape: a trigger, then a list of stages, each with commands to run.
on: [push]
stages:
- build:
run: npm run build
- test:
run: npm test
- deploy:
run: ./deploy.sh
when: branch == main
Output:
Committed to the repo, reviewed like any other code change
Why it beats clicking in a UI
Because the pipeline lives in version control, changes to it go through pull requests, get reviewed, and can be rolled back — just like application code.
Quick check: What is the main benefit of pipeline-as-code over configuring a pipeline through a UI?
- It runs faster than any UI-based pipeline
- It is version-controlled, reviewable, and revertable like application code
- It removes the need for a test stage
Answer
It is version-controlled, reviewable, and revertable like application code — The pipeline definition sits in the repo, so it's tracked, diffable, and reviewable exactly like the code it builds and deploys.