Skip to content
Permalink
Browse files

Preliminary doc update for JENKINS-46547

  • Loading branch information...
abayer committed Sep 18, 2017
1 parent b369083 commit 7009b1682960bdae12d5bfb54540dcff68529944
Showing with 50 additions and 0 deletions.
  1. +50 −0 content/doc/book/pipeline/shared-libraries.adoc
@@ -620,3 +620,53 @@ library sources will not be checked out again.)

_Replay_ is not currently supported for trusted libraries.
Modifying resource files is also not currently supported during _Replay_.

=== Defining Declarative Pipelines

Starting with Declarative 1.2, released in late September, 2017, you can define
Declarative Pipelines in your shared libraries as well. Here's an example,
which will execute a different Declarative Pipeline depending on whether the
build number is odd or even:

[source,groovy]
----
// vars/evenOrOdd.groovy
def call(int buildNumber) {
if (buildNumber % 2 == 0) {
pipeline {
agent any
stages {
stage('Even Stage') {
steps {
echo "The build number is even"
}
}
}
}
} else {
pipeline {
agent any
stages {
stage('Odd Stage') {
steps {
echo "The build number is odd"
}
}
}
}
}
}
----

[source,groovy]
----
// Jenkinsfile
@Library('my-shared-library') _
evenOrOdd(currentBuild.getNumber())
----

Only entire `pipeline`s can be defined in shared libraries as of this time.
This can only be done in `vars/*.groovy`, and only in a `call` method. Only one
Declarative Pipeline can be executed in a single build, and if you attempt to
execute a second one, your build will fail as a result.

0 comments on commit 7009b16

Please sign in to comment.
You can’t perform that action at this time.