Build once, and know what you built
Every environment runs the same artifact, and every artifact can name the exact commit and pipeline that produced it.
The rule
Continuous Delivery lists it among the first pipeline practices: only build your binaries once. The commit stage produces an artifact, such as an image, a package, or a tarball, and every later stage, including production, uses that artifact. Rebuilding later, even "with the same Dockerfile", produces a different artifact. A base image tag may have moved, a dependency range may resolve to a new patch, a build flag may differ, or someone may check out a different commit. The tests you ran then vouch for something you are not shipping.
Its twin practice is deploy the same way to every environment. When the deploy to staging is the same script as the deploy to production, every staging deploy is also a test of the production deploy.
Provenance: make the artifact say where it came from
An artifact should answer "what are you?" without anyone consulting a spreadsheet:
ARG GIT_COMMIT
LABEL org.opencontainers.image.revision=$GIT_COMMIT \
org.opencontainers.image.source=https://git.example/northstar/waybill
A /version endpoint or --version flag that prints the commit and build ID serves the same purpose at run time. The pipeline should record, for each release, the artifact digest, the source commit, and the pipeline run that tested it. With that record, "is production running what we tested?" is a single comparison.
Supply-chain frameworks formalise the idea. SLSA-style attestations are signed statements of how and from what an artifact was built. The Secure Operations track returns to them. The habit starts here, with labels and records.
How artifacts go stale
The labs reproduce the common ways the guarantee breaks:
- Rebuild at deploy: the deploy host builds its own image from its own checkout.
- Mutable tags: the pipeline pushes
waybill:latest, and the deployer pullslatestlater, after another build has overwritten it. - Cached artifacts: a build step reuses an output directory from a previous run, so the "new" artifact contains old code.
- Deploy by branch: the deploy job checks out
mainat deploy time, not the commit that passed.
Each looks fine in isolation, with a green pipeline and a successful deploy. Comparing provenance on both sides catches all of them.
Configuration stays outside
If production differs from staging, the difference must be configuration, supplied at deploy time from version-controlled, reviewed sources (Ch. 2). This is the Twelve-Factor config rule from the Containers in Production track, viewed from the pipeline. One artifact plus per-environment config is testable. Per-environment artifacts are not.
Promotion, not reconstruction
A healthy pipeline moves references. The commit stage pushes waybill@sha256:3f1c… to the registry and records it. Acceptance deploys that digest, and production deploys that digest. Nothing downstream ever runs build. If a later stage finds a problem, the fix is a new commit and a new candidate, not a patch applied to the artifact in place.
Key terms
- Release candidate
- An artifact produced by the commit stage that may be released if it passes every later stage.
- Provenance
- The verifiable record of where an artifact came from, such as source commit, build job, builder, and inputs.
- Artifact repository
- The store (registry, package repository) that holds built artifacts by immutable identity for promotion.
- Promotion
- Moving the same artifact to the next environment, by reference, without rebuilding.
Read further
- Continuous Delivery, Ch. 5, "Anatomy of the Deployment Pipeline" (Purchase; summaries are free on the book's site)
The deployment pipeline practices, especially "Only Build Your Binaries Once" and "Deploy the Same Way to Every Environment". Note the argument about what rebuilding does to the evidence from earlier stages. - Continuous Delivery, Ch. 2, "Configuration Management" (Purchase; summaries are free on the book's site)
Keeping everything needed to rebuild in version control, and managing application configuration separately from binaries. - The DevOps Handbook, 2nd edition, Part III, "The First Way — The Technical Practices of Flow" (Purchase)
The chapters on creating the foundations of the deployment pipeline and enabling low-risk releases, and how a single source of truth for artifacts supports flow.