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 →
- Add to the Jenkinsfile:
options { disableConcurrentBuilds(abortPrevious: true) } - Confirm the branch source discovers PRs and excludes branches filed as PRs, so each push builds once.
- Keep
mainbuilds 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.
More on 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.IntermediateUnit tests, lint, dependency audit and SAST run sequentially and take 22 minutes. How do you restructure the pipeline?BeginnerDevelopers want to rerun only the deploy stage when it fails due to a flaky cluster API, without rebuilding the image. What do you offer?IntermediateA pipeline must run integration tests against a shared staging database that can only handle one test run at a time across four different repos. How do you coordinate?IntermediateA library must be tested on Node 18, 20 and 22, on Linux and Windows, but Node 18 on Windows is not supported. Design the stage.IntermediateYour 700-line Jenkinsfile now fails with `Method code too large!`. You need a fix today and a plan for next month.Advanced