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

Parallel stages or branches can only be included in a top-level stage

    Details

    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          scags9876 John Scaglione added a comment -

          This issue is affecting me too.  Even when using the example pipeline from the documentation, jenkins throws an error.

           

          https://jenkins.io/doc/book/pipeline/syntax/#sequential-stages

          Show
          scags9876 John Scaglione added a comment - This issue is affecting me too.  Even when using the example pipeline from the documentation, jenkins throws an error.   https://jenkins.io/doc/book/pipeline/syntax/#sequential-stages
          Hide
          ddj116 Dan Jordan added a comment -

          Same issue, as soon as I attempt parallel stages at a lower level I get the error:

          WorkflowScript: 25: Parallel stages or branches can only be included in a top-level stage
          Show
          ddj116 Dan Jordan added a comment - Same issue, as soon as I attempt parallel stages at a lower level I get the error: WorkflowScript: 25: Parallel stages or branches can only be included in a top-level stage

            People

            • Assignee:
              Unassigned
              Reporter:
              brianjmurrell Brian J Murrell
            • Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated: