Interview Prep/Jenkins/Pipeline design & Jenkinsfile decisions

Some tests are flaky and fail one build in ten. Product wants green builds now. What do you do in Jenkins, and what do you refuse to do?

IntermediateScenarioPipeline design & Jenkinsfile decisions
Answer

Situation read → Retrying the whole stage hides real failures; we need targeted mitigation and tracking.

What I'd do →

  1. Retry at the test-framework level for known flaky tests only (jest --retryTimes scoped by tag, Maven Surefire rerunFailingTestsCount=2); Surefire reports flakes in XML.
  2. Track flaky tests with JUnit history and quarantine them into a separate non-blocking stage using catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE').
  3. Use retry with conditions: [agent(), kubernetesAgent()] only for infra failures.
  4. Refuse a blanket retry(3) around the test stage.

Why → Blind retries turn real intermittent bugs into invisible production incidents.

Interview tip → Separate infra flakiness (retry) from test flakiness (fix or quarantine).

All Jenkins questions Roadmap: Jenkins

More on Pipeline design & Jenkinsfile decisions