A pipeline runs a 3-hour performance test. If the controller restarts mid-run, the build is lost. How do you make long builds resilient?
AdvancedScenarioPipeline design & Jenkinsfile decisions
Answer
Situation read → Durability, agent survival and step design all matter.
What I'd do →
- Use
durabilityHint('MAX_SURVIVABILITY')for this pipeline. - Run the test on a static agent or a pod that survives controller restarts (pods are not deleted when the controller restarts; they reconnect if the controller returns within the agent's timeout).
- Use plain
shsteps (durable tasks) which keep running and writing output to the agent during the restart. - Do maintenance with quiet-down so new long builds do not start before a planned restart.
- Better: trigger the perf test in an external system and have Jenkins wait on it, so Jenkins restarts do not matter.
Why → Pipeline resume needs persisted CPS state plus a surviving agent and a durable step.
Interview tip → Explain that sh is durable because output goes to files on the agent, not the channel.
More on 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?BeginnerA 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.Intermediate