Interview Prep/Jenkins/Pipeline design & Jenkinsfile decisions

A deploy pipeline waits on `input` for approval, and on Monday you find 14 pods sitting idle since Friday. Fix it.

IntermediateScenarioPipeline design & Jenkinsfile decisions
Answer

Situation read → The input step is inside a stage that holds an agent, so each waiting build keeps a pod (and its resource requests) alive.

What I'd do →

  1. Use agent none at the top and give build stages their own agent.
  2. Move the approval to a stage-level input directive with no agent and a timeout:
    stage('Approve prod') {
      options { timeout(time: 8, unit: 'HOURS') }
      input { message 'Deploy to prod?'; submitter 'release-managers' }
      steps { echo 'Approved' }
    }
    
  3. Run the actual deploy in the next stage with its own deploy pod.
  4. Add milestone() or abortPrevious so an older build cannot be approved after a newer one.

Why → Waiting on the controller costs nothing; waiting inside an agent costs a pod per build.

Interview tip → Always say "timeout on every input"; unbounded approvals are a classic Jenkins smell.

All Jenkins questions Roadmap: Jenkins

More on Pipeline design & Jenkinsfile decisions