Skip to content
AI Engineer Guide.

concept · basics · intermediate · concept 22 of 24

CI/CD

0 of 24 complete

Why it matters

Continuous delivery exists to make the cost of a change small and the evidence about it reliable. The two failure modes are a pipeline that tests something other than what ships, and a pipeline so slow that changes batch up and the first real test is production. Both are fixed by the same discipline: one artefact, fast deterministic checks, and a promotion path that can be reversed.

Mental model

It is a factory line with an inspection station at each step: the same item moves through, and each station can stop the line. The analogy breaks because software can be duplicated, so promoting one artefact rather than rebuilding it is a choice, not a physical constraint.

How it works

Mechanism, step by stepInteractive
  1. 1Trigger on every push to the shared branch, and make the pipeline the only path to production.
  2. 2Build one immutable artefact, tag it with the commit, and promote that artefact through environments.
  3. 3Order checks by speed: static analysis, unit tests, integration tests, then a small end-to-end set.
  4. 4Run migrations as a separate, backward-compatible step so old and new application versions can coexist.
  5. 5Gate promotion on the checks that predict production failure, and keep a manual approval only where human judgement is required.
  6. 6Automate rollback to the previous artefact and rehearse it, including the database state.

Step 1 of 6

Trigger on every push to the shared branch, and make the pipeline the only path to production.

Step 1/6 · step 1

Figure. The mechanism in this page's own steps. The figure adds sequence, not new claims.

What to notice. A step can be read alone, but the order is the mechanism. The control lets you stop on any one.

Text version

The page's steps: 1. Trigger on every push to the shared branch, and make the pipeline the only path to produc… 2. Build one immutable artefact, tag it with the commit, and promote that artefact through e… 3. Order checks by speed: static analysis, unit tests, integration tests, then a small end-t… 4. Run migrations as a separate, backward-compatible step so old and new application version… 5. Gate promotion on the checks that predict production failure, and keep a manual approval … 6. Automate rollback to the previous artefact and rehearse it, including the database state.

  1. Trigger on every push to the shared branch, and make the pipeline the only path to production.
  2. Build one immutable artefact, tag it with the commit, and promote that artefact through environments.
  3. Order checks by speed: static analysis, unit tests, integration tests, then a small end-to-end set.
  4. Run migrations as a separate, backward-compatible step so old and new application versions can coexist.
  5. Gate promotion on the checks that predict production failure, and keep a manual approval only where human judgement is required.
  6. Automate rollback to the previous artefact and rehearse it, including the database state.

Trade-offs

ChoiceGood forCostFails when
Trunk-based developmentSmall changes and fast integrationRequires feature flags and disciplineThe team cannot keep the branch green
Long-lived branchesIsolation for large changesMerge pain and late integrationReleases are frequent
Full end-to-end suite per commitHigh confidenceSlow and flakyThe suite takes longer than the review cycle
Manual promotionHuman judgement on riskDelay and inconsistent gatesReleases are routine
Trade-off mapInteractive

Good for

Small changes and fast integration

Cost

Requires feature flags and discipline

Fails when

The team cannot keep the branch green

  1. The team cannot keep the branch green
  2. Releases are frequent
  3. The suite takes longer than the review cycle
  4. Releases are routine

Figure. Each choice with what it buys, what it costs, and the case where it loses.

What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.

Text version

Four trade-offs: Trunk-based development is good for Small changes and fast integration, costs Requires feature flags and discipline, and fails when The team cannot keep the branch green. Long-lived branches is good for Isolation for large changes, costs Merge pain and late integration, and fails when Releases are frequent. Full end-to-end suite per commit is good for High confidence, costs Slow and flaky, and fails when The suite takes longer than the review cycle. Manual promotion is good for Human judgement on risk, costs Delay and inconsistent gates, and fails when Releases are routine

Failure modes

  • Rebuild per environment. The deployed artefact differs from the tested one because dependencies resolved differently. Debug: compare artefact digests between staging and production for the same release.
  • Flaky gate. The suite fails intermittently and engineers rerun until green. Debug: track pass rate per test over a week and quarantine anything below a stable threshold.
  • Migration without compatibility. The old application version breaks when the new schema is applied. Debug: deploy the migration first and run the previous application version against it in staging.

In production

Track pipeline duration, flake rate and time from merge to production; these predict how often changes are batched. Alert on a rising rollback rate, which usually means the gate is not testing what breaks.

Common misconceptions

People think: Integration means running tests somewhere other than your laptop.

Actually: It means every change is integrated into a shared branch and verified there, which is a workflow property, not a server.

People think: More pipeline stages mean more safety.

Actually: Stages add delay and failure surface; safety comes from the checks that predict real failures and from a fast rollback.

Interview angle

Cover build once, artefact promotion, the ordering of checks and a backward-compatible migration. Name the rollback rehearsal. A list of stages, with no account of what makes the deployed thing identical to the tested thing, is incomplete.

Sources