What is the purpose of separate build and release pipelines (or stages), and why shouldn't you rebuild the application for each deployment environment?
Short answer
Separating build (compile once, producing a single versioned, immutable artifact) from release (deploy that same exact artifact to dev, then staging, then production) ensures you're testing and deploying the literal same binary throughout the pipeline, eliminating the risk of…
Advertisement
AModel answer
Separating build (compile once, producing a single versioned, immutable artifact) from release (deploy that same exact artifact to dev, then staging, then production) ensures you're testing and deploying the literal same binary throughout the pipeline, eliminating the risk of environment-specific build differences causing 'it worked in staging but not production' bugs -- environment-specific configuration should be injected at deploy time (via config files or environment variables), not baked in via a fresh rebuild per environment.
# Build once
dotnet publish -c Release -o ./artifacts
# Deploy the SAME artifact to each environment, varying only config
# Deploy to staging: uses staging appsettings/env vars
# Deploy to production: uses production appsettings/env vars (same binary)Real-world example
A team eliminates a class of 'works in staging, breaks in production' bugs by switching from rebuilding the app separately for each environment to building one artifact once and promoting that exact same build through staging and then production.
Likely follow-ups
- How do you inject environment-specific configuration into an already-built artifact?
- What's the risk of environment-specific compiler directives (#if) breaking this guarantee?
Related topics