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

Building a matrix with exclusions in a declarative pipeline using a pipeline library finds no branches to run

XMLWordPrintable

      I have run into an issue when attempting to build a matrix in a declarative pipeline using a pipeline library through p4.

      If the excludes section is used, the pipeline is run successfully, but it reports that there are no branches to run. Without the excludes section, all targets in the matrix are run.

       

      To reproduce, I created a Perforce instance with Jenkins in a docker network and installed the p4-plugin 1.10.7. I then created a multibranch pipeline with a source of //testDepot/... from perforce.

      I created two streams and a library stream.

       

      In the first stream, I created a Jenkinsfile:

      @Library('test-pipeline') _
      lib()
      

      Where the test-pipeline is a pipeline library at //testDepot/libstream/... with the pipeline code in //testDepot/libstream/vars/lib.groovy

      def call()
      {
        pipeline
        {
          agent any
          stages
          {
            stage('Build')
            {
              matrix
              {
                axes
                {
                  axis
                  {
                    name 'PLATFORM'
                    values 'Linux', 'Windows', 'OSX'
                  }
                  axis
                  {
                    name 'CONFIGURATION'
                    values 'Debug', 'DebugMT', 'DebugNoPCH', 'Release', 'ReleaseMT', 'Retail', 'RetailMT'
                  }
                }
                excludes
                {
                  exclude
                  {
                    axis
                    {
                      name 'PLATFORM'
                      notValues 'Windows'
                    }
                    axis
                    {
                      name 'CONFIGURATION'
                      values 'DebugMT', 'DebugNoPCH', 'ReleaseMT', 'RetailMT'
                    }
                  }
                }
                stages
                {
                  stage('Build')
                  {
                    steps
                    {
                      echo "Building ${PLATFORM} ${CONFIGURATION}"
                    }
                  }
                  stage('Test')
                  {
                    steps
                    {
                      echo "Testing ${PLATFORM} ${CONFIGURATION}"
                    }
                  }
                }
              }
            }
          }
        }
      }

      When run, this pipeline is successful, but nothing runs.

      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Build)
      [Pipeline] parallel
      No branches to run
      [Pipeline] // parallel
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] End of Pipeline
      Finished: SUCCESS

      If the excludes section is commented out, all targets in the matrix are run.

       

      In the second stream, I simply put the pipeline from the groovy into a Jenkinsfile. It runs correctly both with and without the excludes section.

       

      Our declarative pipeline is rather large and complex, and we have run into the "Method code too large" issue. We were hoping that we could get around it by building with a matrix in the declarative pipeline, but have run into this issue instead.

       

            Unassigned Unassigned
            mbrunton27 Matthew Brunton
            Votes:
            11 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated: