[JIRA] (JENKINS-56586) Parallel stages or branches cannot be nested ("can only be included in a top-level stage")

7 views
Skip to first unread message

bitwiseman@gmail.com (JIRA)

unread,
Oct 4, 2019, 12:04:05 PM10/4/19
to jenkinsc...@googlegroups.com
Liam Newman updated an issue
 
Jenkins / Improvement JENKINS-56586
Parallel stages or branches cannot be nested ("can only be included in a top-level stage")
Change By: Liam Newman
Summary: Parallel stages or branches cannot be nested  (" can only be included in a top-level stage ")
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

bitwiseman@gmail.com (JIRA)

unread,
Oct 4, 2019, 12:06:03 PM10/4/19
to jenkinsc...@googlegroups.com
Liam Newman commented on Improvement JENKINS-56586
 
Re: Parallel stages or branches cannot be nested ("can only be included in a top-level stage")

Th error message could be better, but the lack of parallel in parallel is intentional at this time.  I haven't looked into the reasoning. 

brian.murrell@intel.com (JIRA)

unread,
Oct 4, 2019, 2:12:02 PM10/4/19
to jenkinsc...@googlegroups.com

the lack of parallel in parallel is intentional at this time

Indeed. But it's quite limiting, unfortunately.

I wouldn't image a scenario of wanting to do multiple tests in parallel across multiple distros, in parallel of course, would be all that uncommon.

sergio_miram@hotmail.com (JIRA)

unread,
Oct 21, 2019, 7:45:06 AM10/21/19
to jenkinsc...@googlegroups.com

You can use a script and run the parallel in there:

 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') {
                            script {
                              parallel([
                                  'Test 1': { echo "Test 1" },
                                  'Test 2': { echo "Test 2" },
                                  'Test 3') { echo "Test 3" }
                              ])
                            }
                        }
                    }
                }
                stage('Build Platform 2') { steps { echo "Build Platform 2" } }
                stage('Build Platform 3') { steps { echo "Build Platform 3" } }
            }
        }
    }
}

I

sergio_miram@hotmail.com (JIRA)

unread,
Oct 21, 2019, 7:46:03 AM10/21/19
to jenkinsc...@googlegroups.com
Sergio Mira edited a comment on Improvement JENKINS-56586
You can use a script and run the parallel in there as a workaround in declarative pipelines :
{noformat}

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') {
                     script {
                     parallel([
                     'Test 1': { echo "Test 1" },
                     'Test 2': { echo "Test 2" },
                     'Test 3') { echo "Test 3" }
                     ])
                     }
                     }
                    }
                }
                stage('Build Platform 2') { steps { echo "Build Platform 2" } }
                stage('Build Platform 3') { steps { echo "Build Platform 3" } }
            }
        }
    }
}{noformat}
I
Reply all
Reply to author
Forward
0 new messages