How do you version, store and promote build artifacts across environments?
Immutable artifacts
- Build the jar and image once per commit. Tag images with the git SHA (and optionally a semantic version for releases); never rebuild for staging or production, and never reuse tags such as
latestin deployments. - Deploy by digest (
image@sha256:...) or SHA tag so what runs is exactly what was tested. - Store artifacts in a registry (Nexus or Artifactory for jars; ECR, Artifact Registry, GHCR or Harbor for images) with retention policies.
Versioning
- Semantic versioning (MAJOR.MINOR.PATCH) for libraries and public APIs, derived automatically from conventional commits (semantic-release) or tags.
- Services often use a build number or
date-shabecause consumers depend on the API contract, not the binary version.
Configuration per environment
- The same image runs everywhere; environment differences come from configuration: Spring profiles, environment variables, ConfigMaps and Secrets, or a config server.
- Keep environment configuration in Git (Helm values or Kustomize overlays per environment) and secrets in a secrets manager.
Promotion
A promotion is a change that points an environment at an already-tested artifact, ideally a pull request to the GitOps repository updating the image tag for staging and then production, which gives an audit trail and approvals.
Follow-up questions interviewers ask
Try answering each one before you open it.
How do you ensure the image in production is the one your pipeline built?
Sign images in the pipeline with cosign (keyless with OIDC, or with a KMS key), attach SBOM and provenance attestations (SLSA), and enforce verification at admission time in Kubernetes with Kyverno, OPA Gatekeeper or Sigstore's policy controller, so unsigned or unscanned images are rejected.