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

env.STAGE_NAME and Blue Ocean output change after when block in matrix

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • pipeline
    • None
    • Jenkins 2.319.3

      It would seem that when you create a declarative pipeline with a matrix in it, the env.STAGE_NAME property changes from the time that a when {} block in the matrix is processed to when the main stage() and post blocks are run.

      Additionally, it would seem that the Blue Ocean output changes at that time and that all of the steps that were processed in the when {} block disappear once the matrix's stage() block starts running.

      As an example, given the following matrix:

                  matrix {
                      axes {
                          axis {
                              name 'TEST_BRANCH'
                              values 'master',
                                     'release/2.2',
                                     'release/2.0',
                                     'weekly-testing',
                                     'weekly-testing-2.2',
                                     'weekly-testing-2.0'
                          }
                      }
                      when {
                          beforeAgent true
                          expression {
                              println('when: ' + env.STAGE_NAME) || true
                          }
                      }
                      stages {
                          stage('Test Library') {
                              steps {
                                  println('main: ' + env.STAGE_NAME)
                              } //steps
                              post {
                                  always {
                                      println('post -> always: ' + env.STAGE_NAME)
                                  }
                              } // post
                          } // stage('Test Library')
                      } // stages
                  } // matrix
      

      produces the following:

      We don't even need to wait for the post->always stage. We can see in the matrixed stage where the println('main: ' + env.STAGE_NAME) is even env.STAGE_NAME has changed.

      As for the Blue Ocean rendering when this env.STAGE_NAME change happens, here is what a pipeline looks like for a brief period, showing any steps and output processed as part of the when {} block:

      But a few seconds later, I suspect shortly after the env.STAGE_NAME changes, most of the above disappears from the same B/O view:

      Notice also the stage name change circled in purple at the top left of the above screenshot compared to the one above it.

            Unassigned Unassigned
            brianjmurrell Brian J Murrell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: