Interview Prep/Jenkins/Pipeline design & Jenkinsfile decisions

A team's PR builds pile up: every push to an open PR starts a new 25-minute build while the old one keeps running. What do you change?

BeginnerScenarioPipeline design & Jenkinsfile decisions
Answer

Situation read → Outdated builds waste executors and pods; only the newest commit matters for a PR.

What I'd do →

  1. Add to the Jenkinsfile:
    options { disableConcurrentBuilds(abortPrevious: true) }
    
  2. Confirm the branch source discovers PRs and excludes branches filed as PRs, so each push builds once.
  3. Keep main builds unaborted if every commit must be built: disableConcurrentBuilds(abortPrevious: env.BRANCH_NAME != 'main').

Why → abortPrevious cancels the running build of the same job when a new one starts, freeing capacity immediately.

Interview tip → Mention that each PR is its own child job in multibranch, so this only affects builds of the same PR.

All Jenkins questions Roadmap: Jenkins

More on Pipeline design & Jenkinsfile decisions