Skip to article content
FrontendXLesson 16 / 16

Capstone: a safe delivery pipeline

Move from a laptop shell to a safe, observable delivery pipeline: version control, Linux processes and permissions, container images, networking, configuration and secrets, deployment, health checks, observability, rollback, reproducibility and security hardening.

advanced · about 60 minutes · 3 exercises

  • Implement
  • Test
  • Interview

What you will be able to do

#
  • Design a pipeline with quality gates from commit to production.
  • Define artifacts, promotion and rollback for the pipeline.
  • Connect deployment to observability so a bad release is detected and reverted.

Overview

#

This capstone assembles the course: a pipeline that takes a commit, builds a reproducible artifact, runs quality gates, deploys safely, verifies health and observability, and can roll back. Each stage has a clear pass or fail condition.

Pipeline stages

  1. Checkout and restore cache.
  2. Install deterministically (npm ci against a committed lockfile).
  3. Lint and type-check.
  4. Unit and integration tests.
  5. Build the artifact once and tag it immutably (for example by commit SHA).
  6. Scan the image for vulnerabilities and fail on a severity threshold.
  7. Push the artifact to the registry.
  8. Deploy to staging, run smoke tests, then promote the same artifact to production.
  9. Verify health and error-rate metrics after deploy; roll back automatically if guardrails fail.
snippet.txt
commit -> build -> test -> scan -> push -> staging -> smoke -> prod -> verify (auto-rollback on failure)

Quality gates

A gate is a condition that stops promotion. Tests must pass, the scan must be under threshold, and post-deploy metrics must hold. Gates turn a pipeline from a script that runs into a control that decides.

Artifacts and promotion

The artifact is built once and promoted, never rebuilt per environment. The same digest that passed staging is what runs in production, so what you tested is what you ship.

Safety and observability

After deploy, compare error rate and latency against the previous version. If they regress beyond a threshold, roll back automatically. The rollback path must be exercised in staging so it works under pressure.

Common pitfalls

  • Rebuilding the artifact for production, so the tested image is not the shipped image.
  • A scan that reports but never fails the build, so known CVEs ship anyway.
  • Deploying without a post-deploy verification step, so a bad release is discovered by users.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Implement

    List the ordered stages of a pipeline from commit to production, marking which stages are quality gates that can stop promotion.

    starter.text
    # stages with gate markers
    

    Reveal the reference answer
    reference.text
    1. Checkout (no gate). 2. npm ci (no gate). 3. Lint and type-check (gate). 4. Unit and integration tests (gate). 5. Build artifact tagged by commit SHA (no gate). 6. Image scan (gate, fail above severity threshold). 7. Push artifact (no gate). 8. Deploy staging and smoke test (gate). 9. Promote same artifact to production (no gate). 10. Post-deploy metric verification (gate, triggers auto-rollback).

    Authored expected output: A ten-stage pipeline with lint, tests, scan, smoke and post-deploy verification marked as gates.

    Gates are the stages that can refuse to continue. Naming them explicitly shows where a bad change is stopped before it reaches users.

  2. Exercise 2Test

    Write four assertions that verify the pipeline promotes the same artifact it tested, fails on a high-severity vulnerability, and rolls back when post-deploy error rate regresses.

    starter.text
    // describe pipeline assertions
    

    Reveal the reference answer
    reference.text
    1) The image digest deployed to production equals the digest that passed staging. 2) A build with a high-severity finding exits non-zero before push. 3) A simulated error-rate regression after deploy triggers an automatic rollback to the previous digest. 4) The post-deploy verification step reads the error-rate and latency metrics and fails the gate when they exceed the threshold.

    Authored expected output: Four assertions covering artifact identity, scan gating, auto-rollback and metric-based verification.

    These assertions pin the safety properties of the pipeline: what you test is what you ship, known-bad images do not ship, and a bad release is reverted without a human.

  3. Exercise 3Interview

    Describe how you would detect and automatically revert a bad production release within minutes, naming the signals and the mechanism.

    starter.text
    // detection signals and auto-revert mechanism
    

    Reveal the reference answer
    reference.text
    Detect with post-deploy guardrail metrics: error rate by route, latency percentiles and saturation, compared against the previous release's baseline over a short window. The mechanism is a deployment controller that watches those metrics and, on breach, promotes the previous immutable artifact back into service. Keep the previous artifact retained and the rollback path tested in staging. Feature flags can disable the new code path instantly while the revert completes.

    Authored expected output: A plan naming error-rate and latency signals, a metric-watching controller and a retained previous artifact.

    Fast, automatic recovery needs both a signal that fires quickly and a retained, known-good artifact to return to, plus a tested rollback path.

Common misconceptions

#
  • A pipeline is just a script: gates make it a control that can refuse to promote.
  • Rebuilding for production is harmless: it means the tested artifact is not the deployed one.

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.