Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-40443

Possibility to know the current stage in a Pipeline

    Details

    • Similar Issues:

      Description

      I search for a way to know the current stage into a Pipeline, checking the documentation there is not way to do that. as a workaround we could define a environment variable to manage it but it it is not too DRY, Is it possible to evaluate this feature?

      stage('Stage One'){
         env.STAGE = 'Stage One'
         ...
      }
      

      or

      env.STAGE = 'Stage One'
      stage(env.STAGE){
         ...
      }
      

        Attachments

          Issue Links

            Activity

            Hide
            dageissl Daniel Geißler added a comment -

            what would be even cooler is something like:

            stage('Stage One'){
               echo currentStage.name // Stage One
               currentStage.result = 'UNSTABLE' // so we can mark the stage as skipped/unstable/failed if we want to without changing the global result
               ...
            }
            
            Show
            dageissl Daniel Geißler added a comment - what would be even cooler is something like: stage( 'Stage One' ){ echo currentStage.name // Stage One currentStage.result = 'UNSTABLE' // so we can mark the stage as skipped/unstable/failed if we want to without changing the global result ... }
            Hide
            ssbarnea Sorin Sbarnea added a comment - - edited

            It seems that it was implemented as env.STAGE_NAME on JENKINS-44456

            Show
            ssbarnea Sorin Sbarnea added a comment - - edited It seems that it was implemented as  env.STAGE_NAME  on  JENKINS-44456
            Hide
            ssbarnea Sorin Sbarnea added a comment -

            Does anyone knows how to get list of stages in groovy and check their status so I can determine which one failed?

            I want to do this kind of introspection at the end of the pipeline in order to build a nice error message. Due to the nature of the job is not possible to add try/catch blocks on 15-20 stages which are in fact stored in multiple files.

            Show
            ssbarnea Sorin Sbarnea added a comment - Does anyone knows how to get list of stages in groovy and check their status so I can determine which one failed? I want to do this kind of introspection at the end of the pipeline in order to build a nice error message. Due to the nature of the job is not possible to add try/catch blocks on 15-20 stages which are in fact stored in multiple files.

              People

              • Assignee:
                ssbarnea Sorin Sbarnea
                Reporter:
                ifernandezcalvo Ivan Fernandez Calvo
              • Votes:
                13 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: