-
Bug
-
Resolution: Fixed
-
Major
-
None
Here's a trivial example of a general problem:
pipeline { agent any stages { stage ("Example") { steps { // Install dependencies sh 'npm install' echo 'Execute build that creates artifacts' echo 'Execute step that fails to create the expected junit test file' } } } post { always { junit 'reports/**' echo 'This step and everything after it won't run.' archive '**' echo "send email to people with final build status" } } }
I have an always block, but I can't actually guarantee that all steps in that always block will all always attempt to run.
In Scripted Pipeline I could wrap each of these in a try-catch, but I can't do that in Declarative.
I can reorder these steps to put the ones that I know won't fail earlier, but what about the email step? I want that to be last, so it gets the proper build status in the email.
abayer suggested a catchError block. But depending on which step fails, that doesn't get the right behavior either. I want each step in the always to run exactly once no matter the build status. If the second step fails the catchError can't tell which one failed and not to run the first step again.
Logically what I would expect to work:
pipeline { agent any stages { stage ("Example") { steps { // Install dependencies sh 'npm install' echo 'Execute build that creates artifacts' echo 'Execute step that fails to create the expected junit test file' } } } post { always { junit 'reports/**' } always { echo 'This step and everything after it won't run.' } always { archive '** } always { echo "send email to people with final build status" } } }
However, I'm not allowed to have more than one always block.
- relates to
-
JENKINS-41519 Post stages should have well defined order
- Closed
- links to