-
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
[JENKINS-41239] Error during always block skips execution of remaining steps
Attachment | New: Screen Shot 2017-01-25 at 12.32.41 PM.png [ 35617 ] |
So this is an interesting question. The current architecture is such that we can't actually break down each step and execute them individually, so we can't guarantee execution of all the steps. Changing this would be nontrivial at best. I don't think there's a plausible chance of addressing this in the 1.0 timeframe, and even post-1.0, no guarantees - I can go into detail on the problems with that if you'd like.