Interview Prep/Jenkins/Declarative pipeline syntax

How do you set the build result without failing the step?

IntermediateConceptDeclarative pipeline syntax
Answer
unstable(message: 'Coverage below 80%')          // UNSTABLE, continue
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
  sh './integration-tests.sh'
}
warnError('Lint failed') { sh 'npm run lint' }    // stage and build UNSTABLE
error('Missing release notes')                    // fail now

catchError lets the pipeline continue and marks the stage red but the build yellow, which is useful for non-blocking checks.

All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax