Skip to content

Commit

Permalink
Correct or remove references to Pipeline Script where possible
Browse files Browse the repository at this point in the history
There is still some outstanding work which needs to be done in JENKINS-40550 to
update web UI elements to reflect the appropriate "Scripted Pipeline" phrasing.

References WEBSITE-273
  • Loading branch information
R. Tyler Croy committed Dec 20, 2016
1 parent 5a87747 commit 8adf7b8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
38 changes: 23 additions & 15 deletions content/doc/book/pipeline/getting-started.adoc
Expand Up @@ -35,12 +35,12 @@ To learn how to install and manage plugins, consult <<../managing/plugins#, Mana

== Defining a Pipeline

Pipeline Script is written in
Scripted Pipeline is written in
link:http://groovy-lang.org/[Groovy].
The relevant bits of
link:http://groovy-lang.org/semantics.html[Groovy syntax]
will be introduced as necessary in this document, so while an understanding of
Groovy is helpful, it is not required to use Pipeline Script.
Groovy is helpful, it is not required to work with Pipeline.

A basic Pipeline can be created in either of the following ways:

Expand All @@ -49,7 +49,7 @@ A basic Pipeline can be created in either of the following ways:
control repository.

The syntax for defining a Pipeline with either approach is the same, but while
Jenkins supports entering Pipeline Script directly into the web UI, it's
Jenkins supports entering Pipeline directly into the web UI, it's
generally considered best practice to define the Pipeline in a `Jenkinsfile`
which Jenkins will then load directly from source control.
footnoteref:[scm, https://en.wikipedia.org/wiki/Source_control_management]
Expand All @@ -76,9 +76,9 @@ image::pipeline/new-item-creation.png["Enter a name, select *Pipeline*, and clic



* In the *Script* text area, enter a Pipeline script and click *Save*.
* In the *Script* text area, enter a Pipeline and click *Save*.

image::pipeline/hello-world-script.png["In the *Script* text area, enter a Pipeline script and click Save", role=center]
image::pipeline/hello-world-script.png["In the *Script* text area, enter a Pipeline and click Save", role=center]

* Click *Build Now* to run the Pipeline.

Expand Down Expand Up @@ -110,22 +110,23 @@ node { // <1>
[[defining-a-pipeline-in-scm]]
=== Defining a Pipeline in SCM

Complex pipelines are hard to write and maintain within the text area of the
Pipeline configuration page. If necessary, you can write Pipeline scripts
(Jenkinsfiles) in a text editor and access them in Jenkins with the *Pipeline
Script from SCM* option.
Complex Pipelines are hard to write and maintain within the text area of the
Pipeline configuration page. To make this easier, Pipeline can also be written
in a text editor and checked into source control as a `Jenkinsfile` which
Jenkins can load via the *Pipeline Script from SCM* option.

Loading pipeline scripts using the `checkout scm` step leverages the
idea of "Pipeline as Code" and allows easy maintenance of Pipelines with source
control and text-editors.

To do this, select *Pipeline script from SCM* when defining the pipeline.
To do this, select *Pipeline script from SCM* when defining the Pipeline.

With the *Pipeline script from SCM* option selected, you do not enter any Groovy
code in the Jenkins UI; you just indicate by specifying a path where in source
code you want to retrieve the pipeline from. When you update the designated
repository, a new build is triggered, as long as your job is configured with an
SCM polling trigger.
////
XXX: The above contains a reference to ""Pipeline script from SCM" dropdown
which needs to be renamed in a future release of Pipeline:
https://issues.jenkins-ci.org/browse/JENKINS-40550
////

[TIP]
====
Expand Down Expand Up @@ -170,6 +171,13 @@ To generate a step snippet with the Snippet Generator:
. Click *Generate Pipeline Script* to create a snippet of Pipeline which can be
copied and pasted into a Pipeline.


////
XXX: The above contains a reference to "Generate Pipeline Script" button which
needs to be renamed in a future release of Pipeline:
https://issues.jenkins-ci.org/browse/JENKINS-40550
////

image::pipeline/snippet-generator.png[Snippet Generator, role=center]

To access additional information and/or documentation about the step selected,
Expand All @@ -188,7 +196,7 @@ The variables provided by default in Pipeline are:

env::

Environment variables accessible from Pipeline Script, for example:
Environment variables accessible from Scripted Pipeline, for example:
`env.PATH` or `env.BUILD_ID`. Consult the built-in
link:http://localhost:8080/pipeline-syntax/globals#env[Global Variable Reference]
for a complete, and up to date, list of environment variables
Expand Down
20 changes: 10 additions & 10 deletions content/doc/book/pipeline/jenkinsfile.adoc
Expand Up @@ -199,26 +199,26 @@ node {
}
// Declarative not yet implemented //
----
<1> Accessing the `currentBuild.result` variable allows the Pipeline Script to
<1> Accessing the `currentBuild.result` variable allows the Pipeline to
determine if there were any test failures. In which case, the value would be
`UNSTABLE`.

Assuming everything has executed successfully in the example Jenkins Pipeline,
each successful Pipeline run will have associated build artifacts archived,
test results reported upon and the full console output all in Jenkins.

A Pipeline Script can include conditional tests (shown above), loops,
A Scripted Pipeline can include conditional tests (shown above), loops,
try/catch/finally blocks and even functions. The next section will cover this
more advanced Pipeline Script syntax in more detail.
advanced Scripted Pipeline syntax in more detail.


== Advanced Syntax for Pipeline Scripts
== Advanced Syntax for Scripted Pipeline

Pipeline Script is a domain-specific language
Scripted Pipeline is a domain-specific language
footnoteref:[dsl, https://en.wikipedia.org/wiki/Domain-specific_language]
based on Groovy, most
link:http://groovy-lang.org/semantics.html[Groovy syntax]
can be in Pipeline Script without modification.
can be used in Scripted Pipeline without modification.

=== String Interpolation

Expand Down Expand Up @@ -251,7 +251,7 @@ I said, Hello Mr. Jenkins
----

Understanding how to use Groovy's string interpolation is vital for using some
of Pipeline Script's more advanced features.
of Scripted Pipeline 's more advanced features.

=== Working with the Environment

Expand Down Expand Up @@ -285,7 +285,7 @@ node {

Setting an environment variable within a Jenkins Pipeline can be done with the
`withEnv` step, which allows overriding specified environment variables for a
given block of Pipeline Script, for example:
given block of Scripted Pipeline, for example:

[pipeline]
----
Expand Down Expand Up @@ -326,7 +326,7 @@ TODO: Expand this section with more examples

=== Handling Failures

Pipeline Script relies on Groovy's built-in `try`/`catch`/`finally` semantics
Scripted Pipeline relies on Groovy's built-in `try`/`catch`/`finally` semantics
for handling failures during execution of the Pipeline.

In the <<test>> example above, the `sh` step was modified to never return a
Expand Down Expand Up @@ -421,7 +421,7 @@ execution takes 30 minutes to complete, the "Test" stage would now take 60
minutes to complete!

Fortunately, Pipeline has built-in functionality for executing portions of
Pipeline Script in parallel, implemented in the aptly named `parallel` step.
Scripted Pipeline in parallel, implemented in the aptly named `parallel` step.

Refactoring the example above to use the `parallel` step:

Expand Down
25 changes: 13 additions & 12 deletions content/doc/book/pipeline/shared-libraries.adoc
Expand Up @@ -14,7 +14,7 @@ layout: section

As Pipeline is adopted for more and more projects in an organization, common
patterns are likely to emerge. Oftentimes it is useful to share parts of
Pipeline scripts between various projects to reduce redundancies and keep code
Pipelines between various projects to reduce redundancies and keep code
"DRY"
footnoteref:[dry, http://en.wikipedia.org/wiki/Don\'t_repeat_yourself].

Expand Down Expand Up @@ -70,12 +70,13 @@ The `src` directory should look like standard Java source directory structure.
This directory is added to the classpath when executing Pipelines.

The `vars` directory hosts scripts that define global variables accessible from
Pipeline scripts.
Pipeline.
The basename of each `*.groovy` file should be a Groovy (~ Java) identifier, conventionally `camelCased`.
The matching `*.txt`, if present, can contain documentation, processed through the system’s configured markup formatter
(so may really be HTML, Markdown, etc., though the `txt` extension is required).

The Groovy source files in these directories get the same “CPS transformation” as your Pipeline scripts.
The Groovy source files in these directories get the same “CPS transformation”
as in Scripted Pipeline.

A `resources` directory allows the `libraryResource` step to be used from an external library to load associated non-Groovy files.
Currently this feature is not supported for internal libraries.
Expand Down Expand Up @@ -106,7 +107,7 @@ allows scoping of specific libraries to all the Pipelines inside of the folder
or subfolder.

Folder-based libraries are not considered "trusted:" they run in the Groovy
sandbox just like typical Pipeline scripts.
sandbox just like typical Pipelines.

=== Automatic Shared Libraries

Expand All @@ -120,7 +121,7 @@ branch, using an anonymous checkout.

== Using libraries

Pipeline scripts can access shared libraries marked _Load implicitly_, They may
Pipelines can access shared libraries marked _Load implicitly_, They may
immediately use classes or global variables defined by any such libraries
(details below).

Expand Down Expand Up @@ -212,7 +213,7 @@ def checkOutFrom(repo) {
}
----

Which can then be called from a Pipeline Script:
Which can then be called from a Scripted Pipeline:

[source,groovy]
----
Expand Down Expand Up @@ -254,7 +255,7 @@ node {
If the library needs to access global variables, such as `env`, those should be
explicitly passed into the library classes, or methods, in a similar manner.

Instead of passing numerous variables from the Pipeline Script into a library,
Instead of passing numerous variables from the Scripted Pipeline into a library,

[source,groovy]
----
Expand All @@ -267,7 +268,7 @@ class Utilities {
----

The above example shows the script being passed in to one `static` method,
invoked from a Pipeline Script as follows:
invoked from a Scripted Pipeline as follows:

[source,groovy]
----
Expand Down Expand Up @@ -298,7 +299,7 @@ def caution(message) {
}
----

The Pipeline Script can then invoke these methods which will be defined on the
The Pipeline can then invoke these methods which will be defined on the
`acme` object:

[source,groovy]
Expand Down Expand Up @@ -332,12 +333,12 @@ allows the global variable to be invoked in a manner similar to a step:
// vars/sayHello.groovy
def call(String name = 'human') {
// Any valid steps can be called from this code, just like in other
// Pipeline scripts
// Scripted Pipeline
echo "Hello, ${name}."
}
----

The Pipeline Script would then be able to reference and invoke this variable:
The Pipeline would then be able to reference and invoke this variable:

[source,groovy]
----
Expand All @@ -360,7 +361,7 @@ def call(Closure body) {
}
----

The Pipeline Script can then use this variable like any built-in step which
The Pipeline can then use this variable like any built-in step which
accepts a block:

[source,groovy]
Expand Down

0 comments on commit 8adf7b8

Please sign in to comment.