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

Add an `includes` directive to matrix

XMLWordPrintable

      This reddit question has convinced me that we need an "includes" directive for matrix. 

      User wanted a very sparse matrix: 

      Arch Platform OS Variant Device Debug
      aarch64 pine64 mobile pinephone y
      aarch64 pine64 mobile pinephone n
      x86_64 pc desktop generic y
      x86_64 pc desktop generic n

       

      In order to achieve that we had to do this:  

       

          pipeline {
              agent none
              stages {
                  stage('Build') {
                      matrix {
                          agent any
                          axes {
                              axis {
                                  name 'ARCH'
                                  values 'aarch64', 'x86_64'
                              }
                              axis {
                                  name 'PLATFORM'
                                  values 'pine64', 'pc'
                              }
                              axis {
                                  name 'VARIANT'
                                  values 'mobile', 'desktop'
                              }
                              axis {
                                  name 'DEVICE'
                                  values 'pinephone', 'generic'
                              }
                              axis {
                                  name 'DEBUG'
                                  values 'y', 'n'
                              }
                          }
                          excludes {
                              exclude {
                                  axis {
                                      name 'ARCH'
                                      values 'aarch64'
                                  }
                                  axis {
                                      name 'PLATFORM'
                                      notValues 'pine64'
                                  }
                              }
                              exclude {
                                  axis {
                                      name 'ARCH'
                                      values 'aarch64'
                                  }
                                  axis {
                                      name 'VARIANT'
                                      notValues 'mobile'
                                  }
                              }
                              exclude {
                                  axis {
                                      name 'ARCH'
                                      values 'aarch64'
                                  }
                                  axis {
                                      name 'DEVICE'
                                      notValues 'pinephone'
                                  }
                              }
                              exclude {
                                  axis {
                                      name 'ARCH'
                                      values 'x86_64'
                                  }
                                  axis {
                                      name 'PLATFORM'
                                      notValues 'pc'
                                  }
                              }
                              exclude {
                                  axis {
                                      name 'ARCH'
                                      values 'x86_64'
                                  }
                                  axis {
                                      name 'VARIANT'
                                      notValues 'desktop'
                                  }
                              }
                              exclude {
                                  axis {
                                      name 'ARCH'
                                      values 'x86_64'
                                  }
                                  axis {
                                      name 'DEVICE'
                                      notValues 'generic'
                                  }
                              }
                          }
                          stages {
                              stage('Build') {
                                  steps {
                                      sh "bash ./scripts/build.sh x86_64 ${PLATFORM} ${VARIANT} TARGET_DEVICE=${DEVICE} DEBUG=${DEBUG} TIDY=y"
                                  }
                              }
                          }
                      }
                  }
              }
          }
      

       

      This is admittedly an extreme case but it seem like it isn't so unusual

       

      https://www.reddit.com/r/jenkinsci/comments/fzlfmb/jenkinsfile_matrix/

            bitwiseman Liam Newman
            bitwiseman Liam Newman
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: