Interview Prep/CI/CD/Jenkins Pipelines and Agents

A stage fails on a transient test flake, but you still want the build to continue and report unstable. How?

IntermediateScenarioJenkins Pipelines and Agents
Answer

Situation read → Not every failure should abort the pipeline, but it must not be hidden.

What I'd do →

catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
  sh './run-integration-tests.sh'
}

Publish results with junit 'target/surefire-reports/*.xml', which marks the build UNSTABLE on test failures.

Why → The stage shows red, the build stays visible as unstable, and later stages like archiving still run.

Interview tip → Say you track flaky tests and fix them; catchError is a bandage, not a strategy.

All CI/CD questions

More on Jenkins Pipelines and Agents