Interview Prep/Jenkins/Pipeline design & Jenkinsfile decisions

Developers want to rerun only the deploy stage when it fails due to a flaky cluster API, without rebuilding the image. What do you offer?

IntermediateScenarioPipeline design & Jenkinsfile decisions
Answer

Situation read → Rebuilding is slow and produces a different artifact; we want to retry with the same image.

What I'd do →

  1. Ensure the deploy stage is a top-level declarative stage so Restart from Stage is available.
  2. Pass the image tag through env computed from the commit (deterministic), not from a stash.
  3. Add automatic retry only for infrastructure errors around the API calls: retry(count: 2, conditions: [kubernetesAgent(), nonresumable()]), plus a retry(2) around kubectl apply with backoff.
  4. Enable preserveStashes(buildCount: 5) if the stage needs stashed manifests.

Why → Restart from Stage reuses earlier stage results and redeploys the exact same artifact.

Interview tip → Connect to "build once, deploy many".

All Jenkins questions Roadmap: Jenkins

More on Pipeline design & Jenkinsfile decisions