Skip to content

Commit

Permalink
[JENKINS-44461] Add documentation for new when->beforeAgent field
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed Dec 20, 2017
1 parent 4cb63ac commit 09ee781
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions content/doc/book/pipeline/syntax.adoc
Expand Up @@ -767,6 +767,15 @@ anyOf:: Execute the stage when at least one of the nested conditions is true.
Must contain at least one condition.
For example: `when { anyOf { branch 'master'; branch 'staging' } }`

===== Evaluating `when` before entering the `stage`'s `agent`

By default, the `when` condition for a `stage` will be evaluated after
entering the `stage`'s `agent`, if one is defined. However, this can
be changed by specifying the `beforeAgent` option within the `when`
block. If this is specified and is true, the `when` condition will be
evaluated first, and the `agent` will only be entered if the `when`
condition evaluated to true.

[[when-example]]
===== Examples

Expand Down Expand Up @@ -907,6 +916,34 @@ pipeline {
// Script //
----

.`beforeAgent`
[pipeline]
----
// Declarative //
pipeline {
agent none
stages {
stage('Example Build') {
steps {
echo 'Hello World'
}
}
stage('Example Deploy') {
agent {
label "some-label"
}
when {
beforeAgent true
branch 'production'
}
steps {
echo 'Deploying'
}
}
}
}
// Script //
----
=== Parallel

Stages in Declarative Pipeline may declare a number of nested stages within
Expand Down

0 comments on commit 09ee781

Please sign in to comment.