-
Bug
-
Resolution: Unresolved
-
Critical
-
-
Declarative backlog
In a longer pipeline it is possible that one needs to check if a step has been restarted more than one time.
Lets say steps 3 and 7 must behave different when they are restarted.
If we restart the step 3 the isRestartedRun() will be true and trick step 7 in believing it has been restarted (when it was not, 3 was the one restarted).
We need a way to reset this, perhaps after the first step after the restart is completed.
I marked this as Critical because it really misleads the code in later stages into executing the wrong code based on misinformation. Here is one example:
stages {
stage('DoWork') {
when
}
agent any
steps
}
}
stage('RestartWork') {
when
agent any
steps { <Do it differently because the step was restarted and some things cannot/should not be done again on restart> ) }
}
}
stage('FlagTest') {
when { isRestartedRun() }
agent any
steps
}
}
The last stage above does get executed, as shown in this console output:
[Pipeline] echoisRestartedRun should be false here
- is related to
-
JENKINS-53193 Provide currentBuild.isRestartedRun and .isRestartedStage global variables
-
- Open
-
- links to
[JENKINS-53662] isRestartedRun() is not reset after a successful stage
Status | Original: Open [ 1 ] | New: In Progress [ 3 ] |
Status | Original: In Progress [ 3 ] | New: In Review [ 10005 ] |
Remote Link | New: This issue links to "PR #293 (Web Link)" [ 21928 ] |
Link | New: This issue is related to JENKINS-53193 [ JENKINS-53193 ] |
Labels | New: stage-restart-improvements |
I think the direction I'm going to go with this is to add a new isRestartedStage() when condition that will specifically be true just when checked on the stage that we're restarting at, not with any subsequent stages. I can see valid use cases for isRestartedRun() being true for all stages executed in a restarted run, but the granularity is worth having as well.