Let's say we have the following Jenkinsfile
:
stage name: "Cool stage" sh 'whoami' stage name: "Better stage" def current_stage = getCurrentStageName() echo "CONGRATULATIONS, you are on stage: $current_stage"
The question is how to implement getCurrentStageName()
. I know, that I can get an access to build run-time using currentBuild.rawBuild
. But how to get stage name from that point?
I need this for some customization in email notifications, so that I can always catch failed stage name and include it into email body.
When you run some builds, the stage view will appear with Checkout, Build, and Test columns, and one row per build. When hovering over a stage cell you can click the Logs button to see log messages printed in that stage: after the preceding stage step and before the next one.
It contains a collection of states such as build, deploy, test and release. These jobs or events are interlinked with each other. Every state has its jobs, which work in a sequence called a continuous delivery pipeline.
You can now do this in a built-in manner, since Jenkins 2.3. Like so:
steps { updateGitlabCommitStatus name: STAGE_NAME, state: 'running' echo '${STAGE_NAME}' }
For more information see: https://issues.jenkins-ci.org/browse/JENKINS-44456
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With