Designing build, test, package, and deploy stages as a clear, observable flow.
Designing build, test, package, and deploy stages as a clear, observable flow.
Lesson outline
A good CI/CD pipeline lets you trace a single commit from source control to production through clear stages: source → build → test → package → deploy → verify.
Each stage has a specific purpose and clear inputs/outputs so you can see where work is stuck. The visual pipeline is your value stream for code changes.
Build
Compile code, install deps, create artifacts
Must pass before next stage
Test
Unit, integration, lint, security scans
Must pass before next stage
Package
Push images/packages to registries
Must pass before next stage
Deploy
Promote to staging & production
Green pipeline ⇒ safe to deploy from trunk
Think of each stage as a station in a factory line. Code should only move forward when it passes the station's checks. For example: build must succeed before tests run; tests must pass before a package is pushed.
Good designs keep most checks automated and avoid manual gates except where necessary (e.g. production approvals). Too many manual steps turn the pipeline back into a ticket queue.
Run the fastest, cheapest checks first: linting and unit tests. Then run slower integration, end‑to‑end, and security tests. Fail fast so developers get feedback in minutes, not hours.
From a DevOps perspective, long feedback loops behave like long queues in a factory—you end up discovering problems late, when they are expensive to fix.
Define how code moves between environments: for example, every merge to main deploys to staging; production deploys happen from tagged releases after staging verification.
Automate promotions as much as possible. Avoid “copy this artifact manually” or “click this console button” steps; they create snowflakes and make rollbacks harder.
Start by sketching your current flow on paper: where code lives, how it is built, how tests run, and how deploys happen. Then draw the ideal flow with fewer manual steps.
Implement that ideal flow incrementally: first automate builds and tests, then packaging, then deploys. Measure how long it takes for a change to go from commit to production as you refine the design.
System design and DevOps interviews: expect to whiteboard or describe a complete pipeline from commit to production, justify stage ordering, and discuss failure handling.
Common questions:
Strong answer: Separating stages by speed and blast radius (unit tests first, integration tests after, canary deploy before full rollout). Mentioning artifact immutability (build once, promote everywhere). Discussing rollback strategy and how to detect bad deploys automatically.
Red flags: Describing a pipeline with no automated tests, or manual approvals at every stage. Not knowing the difference between CD (delivery) and CD (deployment). Treating deploy and release as the same thing.
Scenario · Growing e-commerce startup
Step 1 of 3
You have just joined a growing e-commerce startup as a DevOps engineer. The team has a Node.js API service with about 200 unit tests, 30 integration tests (require a real database), and 10 end-to-end tests (use Playwright against a running app). Currently, everything runs in a single sequential job that takes 45 minutes. You have been asked to design a proper pipeline. The company deploys to Kubernetes on AWS (EKS).
You are sketching the pipeline stages on a whiteboard. The team asks: "Should we put all our tests in one stage or split them up?" The unit tests take 2 minutes, integration tests take 18 minutes (require a PostgreSQL container), and e2e tests take 25 minutes (require the full app stack).
What is the best stage design for these tests?
Quick check · CI/CD pipeline design
1 / 3
💡 Analogy
A CI/CD pipeline is a factory production line. Each stage is a quality control station: raw materials (code) enter at one end and a certified, shippable product exits the other. The key insight from lean manufacturing: each station should do one thing, fail loudly if the product is defective, and never pass a known defect to the next station. A long, single-stage pipeline is the equivalent of one massive quality check at the end — you only discover problems after all the work is done.
⚡ Core Idea
The pipeline's job is to answer one question as fast as possible: "Is this commit safe to deploy to production?" Every design decision — stage ordering, parallelisation, caching, test selection — should be evaluated against this goal.
🎯 Why It Matters
Pipeline design directly affects developer behaviour, deployment frequency, and mean time to recovery. A 10-minute pipeline that gives clear signal encourages frequent, small commits. A 60-minute pipeline that often gives false signals encourages batching, branching, and manual overrides — exactly the antipatterns that make deployments risky.
Ready to see how this works in the cloud?
Switch to Career Paths for structured paths (e.g. Developer, DevOps) and provider-specific lessons.
View role-based pathsSign in to track your progress and mark lessons complete.
Questions? Discuss in the community or start a thread below.
Join DiscordSign in to start or join a thread.