I would like the ability to have stage names be dynamic strings. This is useful, for instance, when defining stages within a matrix, so that the stage names can contain the values of the axes. (Part of the problem here is that Blue Ocean doesn't render matrixes well at all.) Right now attempting to do this yields an error because stage names can only be string literals, not Groovy strings (interpolation).

      Note that I am not looking for the steps within the stage to be dynamic.

      Example:

      matrix {
          axes {
              axis {
                  name 'PLATFORM'
                  values 'linux', 'mac', 'windows'
              }
          }
          stages {
              stage("Build ${PLATFORM}") {
                  // ...
              }
              stage("Test ${PLATFORM}") {
                  // ...
              }
              stage("Deploy ${PLATFORM}") {
                  // ...
              }
          }
      }
      

          [JENKINS-61280] Allow dynamic stage names

          Jesse Rittner created issue -
          Liam Newman made changes -
          Assignee Original: Andrew Bayer [ abayer ] New: Liam Newman [ bitwiseman ]

          Liam Newman added a comment -

          Stage names must be resolved before the pipeline starts.

          Since matrix construction is also done before pipeline start, the exact scenario above could be supported.
          However, users would then quite reasonably assume that they could put other variables into those interpolations and would get problems.

          I do not know the reason stage names must be resolved before the pipeline starts, but figuring out how to change that more generally would require some digging.

          Liam Newman added a comment - Stage names must be resolved before the pipeline starts. Since matrix construction is also done before pipeline start, the exact scenario above could be supported. However, users would then quite reasonably assume that they could put other variables into those interpolations and would get problems. I do not know the reason stage names must be resolved before the pipeline starts, but figuring out how to change that more generally would require some digging.
          Stefan Drissen made changes -
          Attachment New: image-2020-03-19-17-20-23-015.png [ 50709 ]
          Stefan Drissen made changes -
          Attachment New: image-2020-03-19-17-20-50-002.png [ 50710 ]
          Stefan Drissen made changes -
          Attachment New: image-2020-03-19-17-22-05-861.png [ 50711 ]

          I'm revisiting replacing a big xml template based multi-job project with a declarative matrix pipeline. While the matrix implementation was really nice and quick to setup, the visualization was a bit of let down. Dynamic stage names would really really really help.

          Current state:

          With stage names based on matrix values:

           

          Stefan Drissen added a comment - I'm revisiting replacing a big xml template based multi-job project with a declarative matrix pipeline. While the matrix implementation was really nice and quick to setup, the visualization was a bit of let down. Dynamic stage names would really really really help. Current state: With stage names based on matrix values:  
          Stefan Drissen made changes -
          Attachment Original: image-2020-03-19-17-20-50-002.png [ 50710 ]

          Big +1 on this. I was able to get a massive job chopped way down thanks to matrix magic, but now the display on Blue Ocean leaves a lot to be desired. Our pipeline view looks very similar to Stefan's ^^ - there's not a clear indicator when one test fails of which one it was.

          I think either:

          a) Display the axes value(s) next to the stage name

          b) Allow for the option to add a variable to a stage name - only invalid inside a matrix directive

          c) Add an option to rename a stage - only valid inside a matrix directive

          Topher Sterling added a comment - Big +1 on this. I was able to get a massive job chopped way down thanks to matrix magic, but now the display on Blue Ocean leaves a lot to be desired. Our pipeline view looks very similar to Stefan's ^^ - there's not a clear indicator when one test fails of which one it was. I think either: a) Display the axes value(s) next to the stage name b) Allow for the option to add a variable to a stage name - only invalid inside a matrix directive c) Add an option to rename a stage - only valid inside a matrix directive

          I think option (a) above would cover enough use cases without making it confusing why dynamic stage names only work inside a matrix.

          James Hollowell added a comment - I think option (a) above would cover enough use cases without making it confusing why dynamic stage names only work inside a matrix.

            bitwiseman Liam Newman
            rittneje Jesse Rittner
            Votes:
            58 Vote for this issue
            Watchers:
            58 Start watching this issue

              Created:
              Updated: