Interview Prep/CI/CD/Jenkins Pipelines and Agents

Two commits land seconds apart and two deploys to the same environment run concurrently, corrupting state. What do you change?

IntermediateScenarioJenkins Pipelines and Agents
Answer

Situation read → Missing mutual exclusion on a shared environment.

What I'd do →

  1. Use options { disableConcurrentBuilds(abortPrevious: true) } for the branch if only the latest matters.
  2. For environment-level locking across jobs use the Lockable Resources plugin: lock(resource: 'prod-deploy') { ... }.
  3. Add milestone() steps so older builds are skipped once a newer one passes that point.

Why → Deploys to one environment must be serialized, and stale builds should not overwrite newer ones.

Interview tip → Mention milestone - many candidates only know disableConcurrentBuilds.

All CI/CD questions

More on Jenkins Pipelines and Agents