Skip to content

Commit

Permalink
Merge pull request #1290 from abayer/jenkins-44461
Browse files Browse the repository at this point in the history
[JENKINS-44461] Add documentation for new when->beforeAgent field
  • Loading branch information
bitwiseman committed Jan 13, 2018
2 parents ff40d07 + bb442af commit 003b9ea
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions content/doc/book/pipeline/syntax.adoc
Expand Up @@ -889,6 +889,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 `agent` for that `stage`, if one is defined. However, this can
be changed by specifying the `beforeAgent` option within the `when`
block. If `beforeAgent` is set to `true`, the `when` condition will be
evaluated first, and the `agent` will only be entered if the `when`
condition evaluates to true.

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

Expand Down Expand Up @@ -1029,6 +1038,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 003b9ea

Please sign in to comment.