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

Allow for nesting Parallel and Matrix blocks

    XMLWordPrintable

Details

    Description

      Apologies if this is a duplicate, but I couldn't find another ticket.

      I'd like to create a job that runs a standalone stage, and a matrix based stage, in parallel. Below is an example of what I'm thinking. The AWS job has different steps / params, so it would be run in parallel to the matrix build, which has several more variants.

      When running the below, the build stops, and tells me `"matrix" or "parallel" cannot be nested inside another "matrix" or "parallel"`.
       

          stage('Build Images') {
            parallel {
              stage ('Build AWS') {
                steps {
                  echo "Running AWS Clone Packer Job"
                  sh 'doing stuff'
                }
              }
      
              stage('Build vCenter') {
                matrix {
                  axes {
                    axis {
                      name 'DC'
                      values 'DC1', 'DC2'
                    }
                    axis {
                      name 'DB'
                      values 'DB1', 'DB2'
                    }
                    axis {
                      name 'TENNANTS'
                      values 'ST', 'MT'
                    }
                  }
                }
                steps {
                  echo "Running vCenter Clone Packer Job"
                  sh "doing something in a matrix"
                }
              }
            }
          }
      

      Attachments

        Issue Links

          Activity

            reddwarf94 Cristian added a comment -

            The documentation explicitly mentions this limitation: "It is not possible to nest a parallel or matrix block within a stage directive if that stage directive is nested within a parallel or matrix block itself." (https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix).

            I guess it was left out when adding "matrix" for some good reason. Not that I'm planning to work on this, but maybe it could help somebody else if there were an explanation of the main challenges to implement this (AFAICS bitwiseman implemented the matrix support).

            People is doing really interesting stuff to overcome this limitation (e.g. https://stackoverflow.com/questions/63878233/running-non-matrix-stages-in-parallel-to-a-matrix-in-jenkins-declarative-pipelin).

            reddwarf94 Cristian added a comment - The documentation explicitly mentions this limitation: "It is not possible to nest a parallel or matrix block within a stage directive if that stage directive is nested within a parallel or matrix block itself." ( https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix ). I guess it was left out when adding "matrix" for some good reason. Not that I'm planning to work on this, but maybe it could help somebody else if there were an explanation of the main challenges to implement this (AFAICS bitwiseman implemented the matrix support). People is doing really interesting stuff to overcome this limitation (e.g. https://stackoverflow.com/questions/63878233/running-non-matrix-stages-in-parallel-to-a-matrix-in-jenkins-declarative-pipelin ).

            People

              Unassigned Unassigned
              herocc CC
              Votes:
              11 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated: