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

Provide a way to access a stage name from within a parallel stage (for scripted pipeline)

      Please provide a way to access the stage name from within a parallel stage (for scripted pipeline).

      Background

      I have a scripted pipeline and within it, I use the 'parallel' step. Within it, I have various stages. I would like to access the env.STAGE_NAME and get the result of the actual parallel stage. Instead, I get the name of the grandparent stage (i.e. stage containing the parallel step).

          [JENKINS-59896] Provide a way to access a stage name from within a parallel stage (for scripted pipeline)

          Charles Murphy created issue -
          Charles Murphy made changes -
          Description Original: Please provide a way to access the stage name from within the stage and its contents (like post).

          *Background*

          I have a multibranch declarative script. I am struggling with the limitation of one JenkinsFile per branch. I want to run various tasks (i.e. stages) on the branch (e.g. build several separate apps) and have a clear indication of which stage failed in the email notification subject sent on failure. I assume that stage processing will stop as soon as one stage fails. The post clause can then call the email-ext plugin and specify in Subject the stage that failed. Developers will then see quickly which task failed, rather than having to look through the console log (or email body).
          New: Please provide a way to access the stage name from within a parallel stage (for scripted pipeline).

          *Background*

          I have a scripted pipeline and within it, I use the 'parallel' step. Within it, I have various stages. I would like to access the env.STAGE_NAME and get the result of the actual parallel stage. Instead, I get the name of the grandparent stage (i.e. stage containing the parallel step).

          Charles Murphy added a comment - - edited

          An acceptable solution, which perhaps is more future-proofed and general, is to provide stage-local memory. If you know about C++ and thread-local memory, then the concept will make sense.

          The idea is that it will become easy for jenkins users to create their own stage wrappers that can modify stage-local memory to perform contextual operations or store contextual data for use later.

          As a concrete example, a stage-local read/write-able env.STAGE object/map could be made available.

          Charles Murphy added a comment - - edited An acceptable solution, which perhaps is more future-proofed and general, is to provide stage-local memory. If you know about C++ and thread-local memory, then the concept will make sense. The idea is that it will become easy for jenkins users to create their own stage wrappers that can modify stage-local memory to perform contextual operations or store contextual data for use later. As a concrete example, a stage-local read/write-able env.STAGE object/map could be made available.
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

            Unassigned Unassigned
            cmurphy208 Charles Murphy
            Votes:
            6 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: