CI/CD & Deployment interview question · Most asked
How do you promote a single build artifact from development through staging to production?
How you'd do it Asked in DevOps Engineer · Site Reliability Engineer (SRE) · QA Engineer / SDET interviews
Summary
Build the artifact once, tag it with the Git SHA, push it to a registry, then deploy that exact artifact to each environment. Never rebuild for staging or production — environment-specific configuration comes from environment variables or config files, not from the build.
Longer Answer
The principle is build once, deploy many: the artifact deployed to production is byte-for-byte identical to the one tested in staging. Rebuilding introduces risk — a dependency might have changed, a flaky build step might produce a different result, or a CI environment difference might alter the output.
Promotion flow:
PR build
→ run tests
→ build image, tag with git SHA (e.g. myapp:abc123f)
→ push to registry
Deploy to dev
→ pull myapp:abc123f
→ inject dev config (env vars, ConfigMap)
Deploy to staging
→ pull myapp:abc123f (same image)
→ inject staging config
→ run smoke tests / integration tests
Deploy to production
→ pull myapp:abc123f (same image)
→ inject prod config
→ requires approval gate
Key practices:
- Immutable tags: tag with the Git SHA, not
latestorv1. This guarantees traceability — you always know which commit is running. - Environment config is external: the image contains the application; environment variables, Kubernetes ConfigMaps or SSM parameters provide the config. The image itself is environment-agnostic.
- Registry as source of truth: the container registry (ECR, GCR, Docker Hub) holds every version. Rollback means redeploying a previous SHA, not rebuilding.
- Approval gates: production deployments require manual approval (GitHub environments, ArgoCD sync policies, Spinnaker pipelines).
- Verification at each stage: smoke tests after each deployment verify the artifact works in that environment before promoting to the next.
What not to do:
- Rebuild the image for each environment (different dependencies, non-reproducible).
- Use
:latesttags (you can't tell what's deployed or roll back deterministically). - Bake environment config into the image (one image per environment = three builds).
Key Points
- Build once, tag with Git SHA, deploy the same artifact to every environment
- Environment config comes from env vars or config maps, never baked into the image
- Immutable tags (Git SHA) guarantee traceability and deterministic rollbacks
- Approval gates and smoke tests at each stage before promoting further
Explanation
What interviewers look for
Look for the "build once, deploy many" principle. Weak answers rebuild per environment or use mutable tags. Strong answers explain why immutability matters for rollbacks and audit trails.
More CI/CD & Deployment questions
- What is shift-left testing, and what security scanning belongs in a CI pipeline?
- What stages does a typical CI/CD pipeline contain?
- How do you handle flaky tests in CI?
- How would you design CI/CD for a microservices architecture?
- What's the difference between continuous integration, continuous delivery and continuous deployment?
- What are best practices for writing Dockerfiles?
- Compare rolling, blue-green and canary deployments.
- How do you run database migrations without downtime?