BitBootcampBitBootcamp ← all explainers 🔄 Review ⚙ Settings

DEVOPS-03-002-P · Primer — Pipelines, Stages, and Gates

The idea in one sentence

A pipeline is the assembly line that carries one code change from commit to production through an ordered sequence of stages, where each stage is a batch of checks and each gate is a pass/fail rule the change must clear before it is allowed to move on — so that problems are caught early, cheaply, and automatically instead of by a customer.

Why it exists

Before pipelines, shipping software meant a person following a runbook: pull the code, run the tests by hand, copy files to a server, cross their fingers. Every release was a bespoke event, the steps drifted from what was written down, and the only place a bug reliably surfaced was in front of a user. The two things that hurt most were inconsistency (nobody ran the exact same steps twice) and late feedback (you found out a change was broken hours or days after you made it, when the context was cold and the fix was expensive).

A pipeline exists to make the path from "I changed a line" to "it's running in production" automated, identical every time, and fast to fail. This is the deployment pipeline pattern from Humble and Farley's Continuous Delivery, and it rests on the discipline Martin Fowler named Continuous Integration: every change is verified against the whole system, automatically, as soon as it lands. The pipeline is the machine that does that verifying.

The payoff is not just automation for its own sake. Because the same ordered checks run on every change, a green pipeline becomes evidence: it tells you this specific build compiled, passed its tests, cleared security scanning, and satisfied whatever release policy you set — without anyone having to remember or vouch for it. That evidence is what lets a team release ten times a day with confidence instead of once a quarter with dread. Google's SRE practice leans on exactly this: releases become boring, repeatable, and reviewable, which is the whole point of release engineering.

How it works

Think of three nested pieces: the pipeline is the whole line, a stage is one section of it, and a gate is the rule that decides whether the change is allowed to leave a stage.

Stages run in a defined order. A typical pipeline reads left to right: build the artifact, run unit tests, run integration tests, do security/quality scans, deploy to staging, run acceptance tests, then deploy to production. The ordering is deliberate and it is an economic decision, not an aesthetic one. Cheap, fast checks go first; slow, expensive checks go last. A compile error should be caught in the ten-second build stage, not discovered forty minutes later during acceptance tests. This is the "fail-fast" principle: put the checks most likely to fail, and cheapest to run, at the front, so the pipeline spends the least time and money to reject a bad change.

A stage is a batch of work with one verdict. Inside a stage you might run hundreds of tests, but the stage as a whole produces a single outcome the pipeline understands: pass or fail. If any required step in the stage fails, the stage fails. This all-or-nothing verdict is what lets stages chain together predictably.

Fail-fast means the pipeline stops on the first failure. When a stage fails, the pipeline halts and the stages downstream do not run. If unit tests are red, you do not waste twenty minutes deploying a broken build to staging just to watch it fall over. The change is rejected, the author gets feedback fast, and no compute is burned proving a thing that was already known. In practice tools model this as a dependency graph — GitHub Actions with needs:, GitLab CI with stages: — where a job only starts once its predecessors succeeded.

A gate is the pass/fail rule at a boundary. Every stage has an implicit gate: "did this stage pass?" But gates also include the explicit policies you attach to a boundary before a change is allowed to advance — especially the boundary into production. Common gates: test coverage must stay above a threshold, no critical vulnerabilities in the security scan, the build artifact must be signed, or a human must click approve. Gates come in two flavors. An automated gate is a machine-evaluated rule (coverage ≥ 80%, zero critical CVEs). A manual gate is a required human sign-off — a release manager or on-call lead approving the promotion to prod. The defining property of any gate is the same: the change cannot cross the boundary until the gate passes. No override without a deliberate, recorded decision.

Put together: a commit enters the pipeline, flows through ordered stages, and at each boundary a gate says yes or no. Green all the way through means the change earned its place in production. Red anywhere means it stops there, and you know exactly which check said no.

The one gotcha

A gate is only as strong as its ability to actually block — and the most common failure mode is a gate that reports red but lets the change through anyway. This happens quietly and constantly. A test suite is marked "continue on error" so a flaky test won't annoy anyone, so now a real failure sails past. A security scan runs but its result isn't wired to fail the stage, so it becomes a dashboard nobody reads. A "required" approval is configured on the wrong branch, so production deploys skip it entirely. In every case the pipeline still shows stages and still looks like it has gates, but the gates are decorative: they observe without enforcing. The rule to internalize is that a gate you can bypass without a deliberate, logged decision is not a gate — it is a suggestion. When you add a check to a pipeline, the real question is never "does it run?" but "when it says no, does the change genuinely stop?" If the answer is "well, usually," you don't have a gate, and the bad change you were guarding against will eventually walk right through it.

See it — a change flows through ordered stages until a gate blocks it

flowchart LR
  C["Commit"] --> B["Build"]
  B --> U["Unit tests<br/>(fast, cheap)"]
  U --> I["Integration<br/>tests"]
  I --> SC["Security scan<br/>(gate: 0 critical)"]
  SC --> ST["Deploy to<br/>staging"]
  ST --> AP["Approval gate<br/>(human sign-off)"]
  AP --> P["Deploy to<br/>production"]
  U -. fails .-> X["Pipeline stops<br/>downstream skipped"]

The one-line takeaway

A pipeline is ordered stages plus enforced gates: cheap checks first so failures are cheap, and every gate must genuinely block — a check that reports red but lets the change through is not a gate.

Where you'll meet it

You'll meet this the first time you open a .github/workflows/*.yml or .gitlab-ci.yml and see stages, needs, and environments with required reviewers — that file is the pipeline, written down. You'll meet it when a red X on a pull request blocks the merge button, and when a deploy to production pauses waiting for someone to click approve. You'll meet the gotcha the hard way when a broken change reaches production and the post-incident review finds a scan that was running all along but was set to "continue on error," so it never actually stopped anything. Interviewers probe it with grounded questions: "why do you run unit tests before integration tests?" (fail-fast: cheapest, most-likely-to-fail checks first), "what's the difference between a stage failing and a gate blocking?" (a failed stage halts the flow; a gate is a policy at a boundary — some gates are just the stage's own verdict, others are extra rules like coverage or human approval), and "how would you stop a change with a failing security scan from deploying?" (wire the scan's result to fail the stage so the gate actually enforces). The strong answer always ties ordering to cost and treats a gate as something that must be able to say no and make it stick.

Named concepts: pipeline, stage, gate