Course map

Topic 186 / Core

CI/CD pipelines: environment parity, security checks in the pipeline, release approval

Chapter 11.5 · CI/CD and Safe Change

What and why

Manually building, testing, and deploying every change doesn't scale past a handful of changes a week and is exactly the kind of repetitive, error-prone process that should be automated. Continuous Integration (CI) automatically builds and tests every change on every commit; Continuous Delivery/Deployment (CD) automatically moves a passing build through environments toward production, with or without a final human gate. Builds on: → 172 (secure development lifecycle: SAST, DAST, dependency scanning, secrets scanning).

Diagram

commit ──► CI [build, tests (→ 197), security checks] ──► artifact (→ 180)
                                                                │
                           CD: deploy to staging ──► deploy to production
                               (gated)                  (gated, maybe approved)

How it works

  1. On every commit, CI builds the code, runs the test suite (→ 197), and — if everything passes — produces a versioned, immutable artifact (typically a container image, → 180) that every later stage deploys unchanged; nothing is rebuilt between staging and production.
  2. Security checks in the pipeline run the same lifecycle controls as development (→ 172): static analysis, dependency scanning, secrets scanning, and dynamic testing further along — a failing security check blocks the pipeline exactly like a failing test, not as an afterthought bolted on before release.
  3. The artifact flows through environments (dev → staging → production) via CD; each environment runs automated checks appropriate to that stage, with increasing confidence required to proceed.
  4. Environment parity means staging is built from the same infrastructure definitions (→ 185) and configuration shape (→ 188) as production, differing only in scale and data — a staging environment that "lies" about production's behavior gives false confidence that fails exactly when it matters.
  5. Release approval is an explicit human gate inserted where regulation or risk demands it — not removed by automation, but made deliberate and visible rather than an ad hoc message before a manual deploy.
  6. The artifact that passes every gate is the one that ships — CD's value is that the thing tested is identical, byte-for-byte, to the thing running in production, removing an entire class of "worked in staging, broke in prod" incidents caused by rebuilding between stages.

Practical example

(numbers illustrative). A team's pre-pipeline release took a manual half-day: build locally, copy to a server, run smoke tests by hand, repeat per environment — with no guarantee the build tested in staging matched what got rebuilt for production. After adopting a pipeline that builds one artifact and promotes it unchanged through automated gates, release time drops to the pipeline's automated run time (often minutes), and the "worked in staging, not in prod" class of bug drops close to zero, because staging and production now run literally the same bits.

When to use it

  • Use CI on every commit, without exception — the value comes from catching problems at the smallest possible diff, which only works if nothing skips it.
  • Use CD with automated gates for most changes; reserve manual release approval for the specific changes where regulation or blast radius genuinely demands a human in the loop.
  • Avoid environments that aren't provisioned the same way as production (→ 185) — if staging is a hand-built pile of exceptions, it stops being predictive of production behavior.
  • Failure scenarios: a pipeline that rebuilds the artifact at each stage instead of promoting one build — reintroducing "it was a different build" as an explanation for failures; security checks configured to warn but never block, so they're silently ignored under deadline pressure; a release-approval gate that exists on paper but is routinely bypassed "just this once," which eventually becomes always.
  • Simpler alternative: for a very small team and a low-risk internal tool, a simple build-and-deploy script run on every commit — no staged environments, no approval gate — is a reasonable start; add staged gates and approval as risk and team size grow, not as a default from day one.

Practice

(process kind, 20–30 min, paper exercise — or hands-on with any CI tool you already have configured). Design a pipeline for a payments-adjacent service: list each stage from commit to production, the specific automated check at each stage, and the one point (if any) needing human release approval — then state what environment-parity gap would make a staging pass meaningless for this specific service. Done when the parity gap you name is specific to the service, not generic.

Key takeaway

CI catches problems on every commit; CD promotes one tested artifact through gated environments toward production, with release approval as a deliberate, visible gate rather than an informal habit. Done when you can: design a pipeline's stages and gates for a given risk profile and name what breaks if staging isn't a faithful copy of production. Used next in → 187 (the deployment strategy the pipeline executes), → 190 (platform engineering templates this pipeline as a paved road).

References

None — this topic makes no external claims.

Source directory

Search the guide