-
Improvement
-
Resolution: Fixed
-
Minor
-
None
In my declarative pipeline I need to repeat the same step in the unstable, failure, and aborted post conditions, e.g.
post { always { // do some stuff to collect junit reports } success { // push the tags } unstable { sh "mvn nexus-staging:drop" } failure { sh "mvn nexus-staging:drop" } aborted { sh "mvn nexus-staging:drop" } }
This is really crappy having to repeat the exact same tidy-up in three places.
What I'd really like is something like:
post { always { // do some stuff to collect junit reports } success { // push the tags } unsuccessful { sh "mvn nexus-staging:drop" } }
Where the unsuccessful steps would run at the end. The sequence of execution would thus be:
- always (first because it might affect the build result)
- success (the result cannot get better, so none of the following blocks can turn the result to a success)
- unstable (because we might have some steps that escalate the unstable to a failure, or get aborted because they take too long)
- failure (once the result is failure, it cannot get better)
- aborted (the failure block could be aborted)
- unsuccessful (a catch-all for any of the previous error modes)
With perhaps a finally condition at the end that always runs
- is related to
-
JENKINS-55476 unsuccessful block is triggered for successful runs
- Closed