jenkinsci / jenkinsci/workflow-aggregator-plugin

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

Open
#970 8 comments 0 reactions 0 assignees View on GitHub
component:pipeline component:workflow-basic-steps-plugin imported-jira-issue priority:critical resolution:unresolved
Dominant language
No language data
Stars
225
Forks
125
PR merge metrics
No merged PRs in 30d

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">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.

---
Originally reported by brianjmurrell, imported from: Parallel stages or branches cannot be nested ("can only be included in a top-level stage")


  • status: Open
  • priority: Critical
  • component(s): pipeline, workflow-basic-steps-plugin
  • resolution: Unresolved
  • votes: 24
  • watchers: 29
  • imported: 2025-12-08

Raw content of original issue

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.