I am currently using Jenkins catchError to catch if an error has occurred within a stage, and if so, then skip to the next stage.
What I would like is to present that if a stage had caught an error, to presented in Jenkins as Red (Failed), even though this stage was skipped to the next.
This is how Jenkins pipeline stage is coded to catch error is script fails:
stage('test_run') {
steps {
catchError {
sh """#!/bin/bash -l
***
npm run test:run:reporter
"""
}
}
}
I found this solution in StackOverflow: Jenkins: Ignore failure in pipeline build step
This solution works, but in Jenkins' run, the stage that failed is presenting Green (aka Success).
This Jenkins run indicates that it failed:
The following stage actually the cause of the failure and was skipped on caught error, however, this stage is showing Green (Success) and prefer to present it to be Red (Failed):
The final post actions is showing as Yellow (Unstable), when normally it shows as Green (Success):
Thank you for reading, always appreciate the assistance.


