I have a stage in my Jenkins declarative pipeline that looks like:
stage('Step Tests') {
steps {
dir('test') {
catchError(catchInterruptions: true, buildResult: 'FAILURE') {
timeout(time: 5, unit: 'MINUTES', activity: true) {
sh "yarn step-tests"
}
}
}
}
}
The timeout activates if my tests don't output anything to the console for 5 minutes, and subsequent stages still execute, which is what I want. However, the build is still marked as aborted instead of failed, which I thought the buildResult
parameter was for.
How do I catch a timeout and mark the build as unstable or failed, instead of aborted?