Why should you build an artifact once and promote the same one through environments?
What they are really testing: Whether you understand immutable, build-once artifacts and that rebuilding per environment causes "works in staging, breaks in prod". A core CD principle.
A real interview question
Why should you build an artifact once and promote the same one through environments?
What most people say
drag me
“It is faster to build once instead of building for each environment.”
Speed is a minor benefit. The real reason is correctness: rebuilding per environment can produce different binaries, so you might test one thing and ship another. Build-once guarantees what you tested is what you ship.
The follow-ups they ask next
How do you handle environment differences if the artifact is identical everywhere?
Inject configuration at deploy/run time (env vars, mounted config, secrets from a manager), not baked into the artifact. The image stays identical; only the surrounding config differs per environment.
How does build-once help with rollback?
Previous immutable, versioned artifacts are stored and ready, so rolling back is just redeploying the prior known-good artifact, no rebuild, exactly what you ran before.
What the interviewer is listening for
- Immutable build-once artifact promoted everywhere
- Knows rebuilding causes staging/prod drift
- Config injected, not baked
What sinks the answer
- Only "it is faster"
- Rebuilds per environment
- Bakes config into the artifact
If you genuinely do not know
Say this instead of freezing. Reasoning out loud from what you do know beats silence every single time, and a good interviewer is listening for exactly that.
“Build the app [once into an immutable versioned artifact (image/package) and promote that same one through dev/staging/prod]. [Rebuilding per environment risks different dependencies/flags, so you test one binary and ship another, works-in-staging-breaks-in-prod]. Build-once means [what you tested is byte-for-byte what you ship]. Inject [config per environment, do not bake it in]. Bonus: [trivial rollback to a prior artifact].”
Keep going with deployment
Foundation
What do CI and CD actually mean, and what is the difference between continuous delivery and continuous deployment?
Junior
What stages should a good CI/CD pipeline have?
Junior
A deploy went bad in production. How do you handle rollback, and how do you make rollback easy?
Junior
What are feature flags, and how do they decouple deployment from release?
Mid
Compare blue-green and canary deployments. When would you reach for each?
Mid
How does your branching strategy affect continuous delivery? Trunk-based versus long-lived branches.
Knowing the answer is not the same as recalling it under pressure
Sign in to send the questions you fumble to spaced recall, so they come back right before you would forget them, and learn the concepts behind them with hands-on labs.
Start free