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

Parallel stages or branches cannot be nested ("can only be included in a top-level stage")

XMLWordPrintable

      When I try to use nested parallel statements in a declarative pipeline as such:

       pipeline {
          agent none
          stages {
              stage('Cancel Previous Builds') { steps { echo "Cancel Previous Builds" } }
              stage('Pre-build') { steps { echo "Pre-build" } }
              stage("Build and Test") {
                  parallel {
                      stage('Build and Test') {
                          stages {
                              stage('Build Platform 1') { steps { echo "Build Platform 1" } }
                              stage('Test Platform 1') { 
                                  parallel {
                                      stage('Test 1') { steps { echo "Test 1" } }
                                      stage('Test 2') { steps { echo "Test 2" } }
                                      stage('Test 3') { steps { echo "Test 3" } }
                                  }
                              }
                          }
                      }
                      stage('Build Platform 2') { steps { echo "Build Platform 2" } }
                      stage('Build Platform 3') { steps { echo "Build Platform 3" } }
                  }
              }
          }
      }

      I get an error:

      WorkflowScript: 25: Parallel stages or branches can only be included in a top-level stage. @ line 25, column 33.
                                         stage('Test 1') { steps { echo "Test 1" } }
                                         ^
       

      A single level of parallel steps is really quite limiting.  I don't think my desired workflow is really all that much "out there".

      From researching this I seem to find a lot of questions about multiple levels of parallel steps but not many answers.

      Is this something that will be supported with declarative at some point?

      To be clear, I don't care about Blue Ocean rendering and visualisation of such nested parallel stages, certainly never any time before JENKINS-39203 since that bug makes Blue Ocean visualisation pretty useless (IMHO) anyway.

      But Blue Ocean aside, it would still be nice to have pipelines that could execute multiple levels of parallel stages.

            Unassigned Unassigned
            brianjmurrell Brian J Murrell
            Votes:
            24 Vote for this issue
            Watchers:
            29 Start watching this issue

              Created:
              Updated: