Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-41334] Add parallel stages documentation
  • Loading branch information
abayer committed Jul 28, 2017
1 parent 779ccff commit 35bd406
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions content/doc/book/pipeline/syntax.adoc
Expand Up @@ -889,6 +889,60 @@ pipeline {
// Script //
----

=== Parallel

Stages in Declarative Pipeline may declare a number of nested stages within
them, which will be executed in parallel. Note that a stage must have one and
only one of either `steps` or `parallel`. The nested stages may use all other
configuration available for stages in Declarative Pipeline, including `when`,
`environment`, `agent`, `post`, and `tools`, but are required to have `steps`
and cannot contain further `parallel` stages themselves. Any stage containing
`parallel` cannot contain `agent` or `tools`, since those are not relevant
without `steps`.

[[parallel-stages-example]]
===== Example

[pipeline]
----
// Declarative //
pipeline {
agent any
stages {
stage('Non-Parallel Stage') {
steps {
echo 'This stage will be executed first.'
}
}
stage('Parallel Stage') {
when {
branch 'master'
}
parallel {
stage('Branch A') {
agent {
label "for-branch-a"
}
steps {
echo "On Branch A"
}
}
stage('Branch B') {
agent {
label "for-branch-b"
}
steps {
echo "On Branch B"
}
}
}
}
}
}
// Script //
----

[[declarative-steps]]
=== Steps

Expand Down

1 comment on commit 35bd406

@Bertg
Copy link

@Bertg Bertg commented on 35bd406 Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please sign in to comment.