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

Incorrect visualization of matrix skipped stages in blue ocean

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • blueocean-plugin
    • None

      The repro is a simple jenkinsfile:

      PROPS = [
          'a': true,
          'b': false,
          'c': true
      ]
      
      pipeline {
          agent none
          stages {
              stage('Main') {
                  matrix {
                      axes {
                          axis {
                              name 'APP'
                              values 'a', 'b', 'c'
                          }
                      }
                      stages {
                          stage('first') {
                              when {
                                  expression {
                                      return PROPS[APP]
                                  }
                              }
                              steps {
                                  echo APP
                              }
                          }
                      }
                  }
              }
          }
      }
      

      It is executed correctly, as is indicated by the job output:

      Running in Durability level: MAX_SURVIVABILITY
      [Pipeline] Start of Pipeline
      [Pipeline] stage (hide)
      [Pipeline] { (Main)
      [Pipeline] parallel
      [Pipeline] { (Branch: Matrix - APP = 'a')
      [Pipeline] { (Branch: Matrix - APP = 'b')
      [Pipeline] { (Branch: Matrix - APP = 'c')
      [Pipeline] stage
      [Pipeline] { (Matrix - APP = 'a')
      [Pipeline] stage
      [Pipeline] { (Matrix - APP = 'b')
      [Pipeline] stage
      [Pipeline] { (Matrix - APP = 'c')
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (first)
      [Pipeline] stage
      [Pipeline] { (first)
      [Pipeline] stage
      [Pipeline] { (first)
      Stage "first" skipped due to when conditional
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] echo
      a
      [Pipeline] }
      [Pipeline] echo
      c
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] }
      [Pipeline] // parallel
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      However, it is visualized incorrectly both in blue-ocean and standard pipeline view. Basically, both a and b branches are visualized as not-executed, a as skipped, b as not built. In reality, a was executed.

      When we put there a random sleep before each parallel branch, the visualization is correct. This is a real problem with some of our pipelines, this is just a toy example how to demonstrate it.

          [JENKINS-63952] Incorrect visualization of matrix skipped stages in blue ocean

          Daniel added a comment -

          Just confirming that we have the exact same problem. We are running four parallell axis, skipping only one. But in blue ocean 2 of them appears skipped.

          Daniel added a comment - Just confirming that we have the exact same problem. We are running four parallell axis, skipping only one. But in blue ocean 2 of them appears skipped.

          Same issue here. It looks like the matrix is not yet widely used (at least not with conditional stages).
          I used the following Jenkinsfile to reproduce the issue:

          pipeline {
              agent none
              stages {
                  stage('matrix') {
                      matrix {
                          axes {
                              axis {
                                  name 'a'
                                  values 'foobar', 'baz'
                              }
                              axis {
                                  name 'b'
                                  values 'bar', 'foo'
                              }
                          }
                          stages {
                              stage ('foo') {
                                  when { expression { a == 'foobar' } }
                                  steps {
                                      echo 'foo stage'
                                  }
                              }
                              stage ('bar') {
                                  steps {
                                      echo 'foo stage'
                                  }
                              }
                          }
                      }
                  }
              }
          }
          

          Joerg Schwaerzler added a comment - Same issue here. It looks like the matrix is not yet widely used (at least not with conditional stages). I used the following Jenkinsfile to reproduce the issue: pipeline { agent none stages { stage( 'matrix' ) { matrix { axes { axis { name 'a' values 'foobar' , 'baz' } axis { name 'b' values 'bar' , 'foo' } } stages { stage ( 'foo' ) { when { expression { a == 'foobar' } } steps { echo 'foo stage' } } stage ( 'bar' ) { steps { echo 'foo stage' } } } } } } }

          Joakim added a comment -

          Hello. Same here, conditional stages doesn't show the correct result. While the stage is working, it is showing status and logs properly. However, once completed, they sometimes show an incorrect result which also prevents you from viewing the logs of the stage.

          Sometimes when the stage status should be skipped, it instead shows as not built, completed stages shows as skipped. It appears to be random.

          Here is my pipeline example:

          pipeline {
              agent none
              stages {
                  stage('Run tests') {
                      matrix {
                          axes {
                              axis {
                                  name 'a'
                                  values 'VS2019', 'x86_64', 'aarch64'
                              }
                              axis {
                                  name 'b'
                                  values 'one', 'two', 'three', 'four'
                              }
                          }
                          agent {
                              label a
                          }
                          stages {
                              // this is working fine
                              stage('Stage without condition') {
                                  steps {
                                      echo "Hello"
                                  }
                              }
                              stage('Conditional step Windows') {
                                  when {
                                      beforeAgent true
                                      expression { a == "VS2019" }
                                  }
                                  steps {
                                      // Simulate work
                                      bat "for /L %%a in (1,1,100) do echo Work %%a && ping -n 2 localhost";
                                  }
                              }
                              stage('Conditional step Linux') {
                                  when {
                                      beforeAgent true
                                      anyOf {
                                          expression { a == "x86_64" }
                                          expression { a == "aarch64" }
                                      }
                                  }
                                  steps {
                                      // Simulate work
                                      sh "for i in {1..100}; do echo 'Work $i'; sleep 1; done"
                                  }
                              }
                          }
                      }
                  }
              }
          }
          

           

           

          Joakim added a comment - Hello. Same here, conditional stages doesn't show the correct result. While the stage is working, it is showing status and logs properly. However, once completed, they sometimes show an incorrect result which also prevents you from viewing the logs of the stage. Sometimes when the stage status should be skipped, it instead shows as not built, completed stages shows as skipped. It appears to be random. Here is my pipeline example: pipeline { agent none stages { stage( 'Run tests' ) { matrix { axes { axis { name 'a' values 'VS2019' , 'x86_64' , 'aarch64' } axis { name 'b' values 'one' , 'two' , 'three' , 'four' } } agent { label a } stages { // this is working fine stage( 'Stage without condition' ) { steps { echo "Hello" } } stage( 'Conditional step Windows' ) { when { beforeAgent true expression { a == "VS2019" } } steps { // Simulate work bat " for /L %%a in (1,1,100) do echo Work %%a && ping -n 2 localhost" ; } } stage( 'Conditional step Linux' ) { when { beforeAgent true anyOf { expression { a == "x86_64" } expression { a == "aarch64" } } } steps { // Simulate work sh " for i in {1..100}; do echo 'Work $i' ; sleep 1; done" } } } } } } }    

          John Smith added a comment - - edited

          In my case, I verified that our "Static analysis" stage did run by checking the logs and the "Pipeline Steps" but Blue Ocean is displaying the stage as skipped (would be in the top row):

          Also same with "Build" stage on the third row.

          This case is prioritized as "Minor", however IMO the bug is rather disruptive and may prevent my team from using matrix altogether. OP mentioned a workaround using sleep. Could someone explain the workaround?

          John Smith added a comment - - edited In my case, I verified that our "Static analysis" stage did run by checking the logs and the "Pipeline Steps" but Blue Ocean is displaying the stage as skipped (would be in the top row): Also same with "Build" stage on the third row. This case is prioritized as "Minor", however IMO the bug is rather disruptive and may prevent my team from using matrix altogether. OP mentioned a workaround using sleep. Could someone explain the workaround?

          same here. I wouldn't say this is a minor bug, as it basically created an inconsistent view of the pipeline execution

          Cristovao Cordeiro added a comment - same here. I wouldn't say this is a minor bug, as it basically created an inconsistent view of the pipeline execution

          CoyoteKG added a comment -

          Same is here.

          In my case it looks like stages in my axes are skiped, even in the one which is not. Also I'm not able to click on some of skipped circles/stages

          CoyoteKG added a comment - Same is here. In my case it looks like stages in my axes are skiped, even in the one which is not. Also I'm not able to click on some of skipped circles/stages

          Peter Niederlag added a comment - - edited

          just running into this when adding matrix {} for my first time. Anything we can do do improve stuff?

          UPDATE: it seems that adding agent

          { kubernetes }

          into the matrix build stages improves the situation....

          Peter Niederlag added a comment - - edited just running into this when adding matrix {} for my first time. Anything we can do do improve stuff? UPDATE: it seems that adding agent { kubernetes } into the matrix build stages improves the situation....

            Unassigned Unassigned
            sebek_dbg Marcel Sebek
            Votes:
            15 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated: