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

Incorrect visualization of matrix skipped stages in blue ocean

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          rulop 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.

          Show
          rulop 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.
          Hide
          macdrega 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'
                                  }
                              }
                          }
                      }
                  }
              }
          }
          
          Show
          macdrega 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' } } } } } } }
          Hide
          andersso 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"
                                  }
                              }
                          }
                      }
                  }
              }
          }
          

           

           

          Show
          andersso 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" } } } } } } }    

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            sebek_dbg Marcel Sebek
            Votes:
            5 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: