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

Blue Ocean Pipeline: only first skipped cell of matrix shown as skipped

    Details

    • Similar Issues:

      Description

      When stages within a matrix are skipped using the 'when' directive, the pipeline result is not rendered correctly. The first cell of the matrix is correctly shown as 'Skipped', however subsequent cells are shown as 'Passed' (in 0s). This is very confusing.

       

      #!groovy
      pipeline {  
        agent none
        parameters {
          booleanParam( name: 'matrix', defaultValue: true )
          booleanParam( name: 'parallel', defaultValue: true )
        }  
        stages {
      
          stage( 'matrix' ) {
            matrix {
              axes {
                axis {
                  name 'server'
                  values 'server-one', 'server-two'
                }
              }
              stages {
                stage( 'matrix' ) {
                  agent {
                    label "${server}"
                  }
                  when {
                    expression { params.matrix }
                  }
                  steps {
                    echo "matrix ${server}"
                  }
                }
              }
            }      
          }
          
          stage( 'parallel' ) {
          
            parallel {
      
              stage( 'parallel-one' ) {
                agent {
                  label 'server-one'
                }
                when {
                  expression { params.parallel }
                }
                steps {
                  echo 'parallel-one'
                }
              }        stage( 'parallel-two' ) {
                agent {
                  label 'server-two'
                }
                when {
                  expression { params.parallel }
                }
                steps {
                  echo 'parallel-two'
                }
              }
              
            }
          }
          
        } // stages
      
      } // pipeline
      

       

        Attachments

          Activity

          Hide
          smd Stefan Drissen added a comment -

          I just discovered that if I use the beforeAgent option on the when directive:

           

           

          #!groovy
          
          pipeline {
          
            agent none
          
            parameters {
              booleanParam( name: 'matrix', defaultValue: true )
              booleanParam( name: 'parallel', defaultValue: true )
            }
          
            stages {
          
              stage( 'matrix' ) {
          
                matrix {
                  axes {
                    axis { 
                      name 'server'
                      values 'server-one', 'server-two'
                    }
                  }
                  stages {
                    stage( 'matrix' ) {
                      agent {
                        label "${server}"
                      }
                      when {
                        beforeAgent true
                        expression { params.matrix }
                      }
                      steps {
                        echo "matrix ${server}"
                      }
                    }
                  }
                }
                
              }
              
              stage( 'parallel' ) {
              
                parallel {
                  
                  stage( 'parallel-one' ) {
                    agent {
                      label 'server-one'
                    }
                    when {
                      expression { params.parallel }
                    }
                    steps {
                      echo 'parallel-one'
                    }
                  }
                  stage( 'parallel-two' ) {
                    agent {
                      label 'sever-two'
                    }
                    when {
                      expression { params.parallel }
                    }
                    steps {
                      echo 'parallel-two'
                    }
                  }
                  
                }
          
              }
              
            } // stages
          
          } // pipeline
          
          

          That the visual result is a lot better:

          There is still some confusion as to what is what, since the first matrix cell reports that it has been skipped, whereas the second cell reports that it was not built.

          Show
          smd Stefan Drissen added a comment - I just discovered that if I use the beforeAgent option on the when  directive:     #!groovy pipeline { agent none parameters { booleanParam( name: 'matrix' , defaultValue: true ) booleanParam( name: 'parallel' , defaultValue: true ) } stages { stage( 'matrix' ) { matrix { axes { axis { name 'server' values 'server-one' , 'server-two' } } stages { stage( 'matrix' ) { agent { label "${server}" } when { beforeAgent true expression { params.matrix } } steps { echo "matrix ${server}" } } } } } stage( 'parallel' ) { parallel { stage( 'parallel-one' ) { agent { label 'server-one' } when { expression { params.parallel } } steps { echo 'parallel-one' } } stage( 'parallel-two' ) { agent { label 'sever-two' } when { expression { params.parallel } } steps { echo 'parallel-two' } } } } } // stages } // pipeline That the visual result is a lot better: There is still some confusion as to what is what, since the first matrix cell reports that it has been skipped , whereas the second cell reports that it was  not   built .

            People

            • Assignee:
              Unassigned
              Reporter:
              smd Stefan Drissen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: