Skip to content

CI/CD Pipeline Design โ€‹

๐Ÿ“ Context โ€‹

A delivery pipeline is how code becomes running software โ€” automatically, repeatably, and safely. For an SE/SA, the job is rarely to write the pipeline; it's to assess, advise, and de-risk the customer's path to production. A weak pipeline is where POCs stall, deployments slip, and "it works on my machine" becomes a support ticket.

This page is the home for the delivery pipeline itself. Deployment strategies live in Deployment Strategies; tool choice in Tooling Selection; securing the pipeline in Pipeline Security.

๐Ÿ“‹ Decision Checklist: Is the Pipeline Healthy? โ€‹

  • [ ] Every change reaches production through the same automated path (no manual hotfixes)
  • [ ] The build is reproducible โ€” same commit produces the same artifact
  • [ ] Tests gate promotion; a red build cannot reach production
  • [ ] Each environment (dev โ†’ staging โ†’ prod) is promoted from the same artifact, not rebuilt
  • [ ] Rollback is a known, rehearsed, one-step action โ€” not an improvisation
  • [ ] Secrets are injected at deploy time, never baked into the artifact
  • [ ] The pipeline emits signal: who deployed what, when, and whether it's healthy

If most of these are no: the customer doesn't have a delivery problem, they have a delivery risk. Name it early โ€” it shapes POC scope, timelines, and go-live confidence.

%%{init: {'theme': 'neutral', 'themeVariables': {'fontSize': '14px'}}}%%
flowchart LR
    S[Source commit] --> B[Build]
    B --> T[Test]
    T --> SC[Scan]
    SC --> P[Package artifact]
    P --> R[Publish to registry]
    R --> G{Promotion gate}
    G -->|pass| D[Deploy to environment]
    D --> V[Verify]
    V --> G

๐Ÿงฉ Worked Scenario: Commit to Production โ€‹

The Order Service from the microservices and API Gateway examples needs a new field on the order payload. A developer merges one commit. Here's the path that change takes โ€” built once, promoted through environments, never rebuilt.

%%{init: {'theme': 'neutral', 'themeVariables': {'fontSize': '14px'}}}%%
flowchart LR
    Dev[Merge to main] --> CI[GitHub Actions build and test]
    CI --> IMG[Image to Amazon ECR]
    IMG --> ARGO[ArgoCD]
    ARGO --> STG[Staging]
    STG --> SMOKE{Smoke tests pass?}
    SMOKE -->|Yes| PROD[Production canary]
    SMOKE -->|No| BLOCK[Block promotion]
    PROD --> WATCH{Error rate normal?}
    WATCH -->|Yes| FULL[Full rollout]
    WATCH -->|No| RB[Auto rollback]
1 ยท Build once
GitHub Actions builds and tests the commit, then publishes one immutable image (tagged by commit SHA) to Amazon ECR.
2 ยท Promote, don't rebuild
ArgoCD deploys that same image to staging. The artifact that ships to prod is byte-for-byte what passed staging.
3 ยท Gate on evidence
Smoke tests in staging are the promotion gate. They pass, or the change does not move forward.
4 ยท Roll out and watch
Production takes the image as a canary, watches error rate, and auto-rolls-back if it degrades โ€” never a 2 a.m. manual revert.

Why this beats "build per environment": rebuilding for prod means the artifact you tested is not the artifact you shipped โ€” the single most common source of "it worked in staging." Build once, promote the same bytes, and staging becomes a real predictor of prod.

Say it like this

"We build the artifact one time and promote that exact image through staging to production. Nothing gets rebuilt on the way โ€” so when staging is green, you're testing the thing that actually ships, not a close cousin of it."

๐ŸŽฏ Core Concepts โ€‹

CI vs. CD vs. CD โ€‹

Three terms, often blurred. Keep them distinct on a whiteboard.

TermWhat it meansEnds when
Continuous IntegrationEvery merge is built and tested automaticallyA tested, packaged artifact exists
Continuous DeliveryThat artifact is always releasable; promotion to prod is a one-click decisionA human approves the release
Continuous DeploymentEvery passing change goes to prod automatically, no human gateThe change is live

The honest distinction: most regulated customers want continuous delivery (auto up to a human-approved prod gate), not continuous deployment. Don't oversell full automation into an environment that needs a change-approval record.

Stages and gates โ€‹

A stage does work (build, test, scan, deploy). A gate decides whether to proceed (tests green, scan clean, approval granted, health stable). Strong pipelines fail at gates early and loudly โ€” a unit-test failure should stop the line in minutes, not surface as a prod incident.

Environment promotion โ€‹

The same artifact moves dev โ†’ staging โ†’ prod, with configuration (not code) injected per environment. Config and secrets are environment-specific; the binary is not.

State the numbers โ€‹

Vague pipeline advice invites the follow-up you can't answer. Ballpark targets below are illustrative โ€” measure the customer's real numbers, don't quote these as fact.

StageIllustrative budgetWhy it matters
Build~6 minSlow builds kill iteration; cache dependencies and layers
Test (unit + integration)~4 minThe fast feedback gate โ€” keep it under the coffee threshold
Image size~120 MBSmaller images pull faster and shrink the attack surface
Staging โ†’ prod promotionminutes, not daysLong promotion windows hide risk and batch changes
Rollback< 5 min, one stepIf rollback is slow or manual, teams avoid deploying

๐Ÿšจ Failure Paths โ€‹

The layer that separates a demo pipeline from a production one is what happens when a stage fails. Every failure should be visible, attributed, and non-destructive.

FailureWhat the pipeline doesWhy
Build failsStop, notify the author, mark the commit redBroken code never produces an artifact
Tests fail in stagingBlock promotion to prod; artifact stays in stagingA red gate is the whole point of the gate
Security scan flags a critical CVEFail the gate, surface the findingShipping a known-critical is worse than a delayed release
Prod deploy degrades (error rate / latency)Auto-rollback to the previous artifactMean-time-to-recovery beats mean-time-to-debug
Migration step fails mid-deployHalt, alert, hold at last-good statePartial deploys are the hardest to reason about
Say it like this

"Failure is a normal pipeline state, not an emergency. A bad build stops at build, a bad change stops at the staging gate, and a bad rollout rolls itself back. The customer's blast radius shrinks at every stage instead of all landing in production."

๐Ÿ‘๏ธ Observability โ€” Who Sees What โ€‹

A pipeline that nobody can see into still generates "is it deployed yet?" Slack threads. Decide deliberately what each audience sees.

AudienceWhat they seeWhy it matters
EngineeringFull build/test logs, per-stage timing, the failing stepDiagnose a red pipeline without guesswork
SecurityScan results, SBOM, which CVEs gated a releaseEvidence for audits; no shipping unknown risk
Product / OpsDeployment status, what's live where, health after releaseAnswer "is it out?" without pinging engineering
Finance / leadershipDeployment frequency, lead time, change-fail rateDelivery health as a business signal, not a vibe

๐ŸŽฏ Evaluating a Customer's Pipeline โ€‹

When reviewing an existing pipeline, look for these smells.

SmellWhat it indicatesRecommendation
Manual steps in the deploy pathTribal knowledge, un-repeatable releasesAutomate the path; a runbook is not a pipeline
Rebuilds the artifact per environmentStaging doesn't predict prodBuild once, promote the same image
No rollback plan (or "redeploy the old branch")Recovery is improvised under pressureMake rollback a one-step, rehearsed action
Tests exist but don't gate promotionGreen is decorativeWire tests to block promotion
Secrets baked into imagesCredential leak waiting to happenInject secrets at deploy via the platform
Deploys batched weekly/monthlyLarge, risky changes; slow recoveryShrink batch size; deploy smaller, more often
No deployment metricsCan't tell if delivery is improvingTrack DORA metrics (see Tooling Selection)

โš ๏ธ Gotchas โ€‹

  • Treating the pipeline as one team's tool โ€” it's a shared contract across dev, security, and ops
  • Building per environment โ€” the artifact you test must be the artifact you ship
  • Gates that warn but don't block โ€” a non-blocking gate is documentation, not control
  • No artifact immutability โ€” overwriting a tag means you can't trust what's deployed
  • Manual rollback โ€” if recovery is slow, teams stop deploying, and changes pile up
  • Ignoring pipeline run time โ€” a 40-minute pipeline is a 40-minute feedback loop
  • Skipping the constrained-environment question โ€” air-gapped and regulated pipelines look very different (see Air-Gapped)

๐Ÿ“š Further reading โ€‹

The research and practice behind good delivery pipelines:

Built as a public field guide for practical Solutions Engineering and Architecture work.