The Stages of a CI/CD Pipeline: Build, Test, Release, Deploy
A pipeline is a sequence of stages, and each stage is a gate: code only moves forward once the previous stage passes.
Pipelines are usually drawn as a left-to-right flow of stages. Understanding what each stage does, and why they run in that order, helps you reason about where failures happen and where to add safeguards. This lesson walks through the four classic stages and the idea of fail-fast ordering.
Build
The build stage turns source code into something runnable: compiling a binary, bundling JavaScript, or assembling a container image. It also resolves and installs dependencies. Build runs first because nothing downstream can proceed without a successful artifact, and compile errors are the cheapest failures to catch.
Test
The test stage runs automated checks against the built code: unit tests, integration tests, linting, and security scans. Tests are typically ordered fast-to-slow so cheap unit tests fail the pipeline early, before expensive integration or end-to-end suites run. This is the heart of continuous integration.
Release
The release stage packages the validated build into a versioned, distributable artifact and publishes it to a registry or repository. This might be tagging a Docker image, pushing a package to a registry, or creating a release with semantic version 1.4.0. Releasing produces an immutable, addressable thing you can later deploy.
Deploy
The deploy stage takes the released artifact and runs it in an environment: staging, then production. Deployments often use strategies like rolling, blue-green, or canary to limit risk. In continuous delivery this stage waits for human approval; in continuous deployment it runs automatically.
Why the order is fail-fast
- Cheapest, fastest checks run first so failures surface in seconds, not minutes.
- Each stage is a gate: a failure halts the pipeline and nothing broken proceeds.
- Expensive stages (deploy to production) only run when everything before them is green.
Key takeaways
- The classic stages are build, test, release, and deploy, in that order.
- Each stage is a gate that must pass before the next one runs.
- Fail-fast ordering puts cheap checks first to surface failures early.