-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Minor
-
Component/s: pipeline-stage-step-plugin
-
None
-
Environment:Jenkins 2.73.3
pipeline-stage-step-plugin 2.3
Hi,
The environment STAGE_NAME variable does not persist when the stage ends prematurely. here's an example:
Ā
node('windows') { try { stage('MY STAGE') { echo "before=" + env.STAGE_NAME error('something bad happened') echo "after=" + env.STAGE_NAME } } catch (def e) { echo "after failure="+env.STAGE_NAME throw e } }
console output:
Started by user admin
[Pipeline] node
Running on SLAVE01 in F:\jenkins-remote\workspace\stagename
[Pipeline] {
[Pipeline] stage
[Pipeline] { (MY STAGE)
[Pipeline] echo
before=MY STAGE
[Pipeline] error
[Pipeline] }
[Pipeline] // stage
[Pipeline] echo
after failure=null
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: something bad happened
Finished: FAILURE
While it makes sense for STAGE_NAME to be null when not in an actual stage, it would be nice if we had a build property or environment variable such as LAST_STAGE_NAME which would keep the last stage executed.Ā This functionality is critical to my shared library logic in which I have a generic script runner and I want to know at which stage the script it ran failed (without having to modify each flow).
It would also be useful if this property would be available when callingĀ getBuildVariables() on a downstream job started by theĀ build step.
- is related to
-
JENKINS-44456 ProvideĀ a way to access a stage name from within the stage and its contents
-
- Resolved
-
- relates to
-
JENKINS-47236 Add stage information to exceptions in pipeline builds
-
- Open
-