Pipeline: Nodes and Processes

bat: Windows Batch Script

Executes a Batch script. Multiple lines allowed. When using the
returnStdout flag, you probably wish to prefix this with
@, lest the command itself be included in the output.

Type:String

encoding (optional)

Encoding of standard output, if it is being captured.

Type:String

returnStatus (optional)

Normally, a script which exits with a nonzero status code will cause the step to fail with an exception. If this option is checked, the return value of the step will instead be the status code. You may then compare it to zero, for example.

Type:boolean

returnStdout (optional)

If checked, standard output from the task is returned as the step value as a
String, rather than being printed to the build log. (Standard error, if any, will still be printed to the log.) You will often want to call
.trim() on the result to strip off a trailing newline.

Type:boolean

node: Allocate node

Allocates an executor on a node (typically a slave) and runs further code in the context of a workspace on that slave.

label

Computer name, label name, or any other label expression like
linux && 64bit to restrict where this step builds. May be left blank, in which case any available executor is taken.

Valid Operators

The following operators are supported, in the order of precedence.

(expr)

parenthesis

!expr

negation

expr&&expr

and

expr||expr

or

a -> b

"implies" operator. Equivalent to !a|b. For example, windows->x64 could be thought of as "if run on a Windows slave, that slave must be 64bit." It still allows Jenkins to run this build on linux.

a <-> b

"if and only if" operator. Equivalent to a&&b || !a&&!b. For example, windows<->sfbay could be thought of as "if run on a Windows slave, that slave must be in the SF bay area, but if not on Windows, it must not be in the bay area."

All operators are left-associative (i.e., a->b->c <-> (a->b)->c ) An expression can contain whitespace for better readability, and it'll be ignored.

Label names or slave names can be quoted if they contain unsafe characters. For example, "jenkins-solaris (Solaris)" || "Windows 2008"

Normally, a script which exits with a nonzero status code will cause the step to fail with an exception. If this option is checked, the return value of the step will instead be the status code. You may then compare it to zero, for example.

Type:boolean

returnStdout (optional)

If checked, standard output from the task is returned as the step value as a
String, rather than being printed to the build log. (Standard error, if any, will still be printed to the log.) You will often want to call
.trim() on the result to strip off a trailing newline.

sh: Shell Script

Otherwise the system default shell will be run, using the -xe flags (you can specify set +e and/or set +x to disable those).

Type:String

encoding (optional)

Encoding of standard output, if it is being captured.

Type:String

returnStatus (optional)

Normally, a script which exits with a nonzero status code will cause the step to fail with an exception. If this option is checked, the return value of the step will instead be the status code. You may then compare it to zero, for example.

Type:boolean

returnStdout (optional)

If checked, standard output from the task is returned as the step value as a
String, rather than being printed to the build log. (Standard error, if any, will still be printed to the log.) You will often want to call
.trim() on the result to strip off a trailing newline.

Type:boolean

ws: Allocate workspace

Allocates a workspace. Note that a workspace is automatically allocated for you with the
node step.

dir

A workspace is automatically allocated for you with the node step, or you can get an alternate workspace with this ws step, but by default the location is chosen automatically. (Something like SLAVE_ROOT/workspace/JOB_NAME@2.)

You can instead specify a path here and that workspace will be locked instead. (The path may be relative to the slave root, or absolute.)

If concurrent builds ask for the same workspace, a directory with a suffix such as @2 may be locked instead. Currently there is no option to wait to lock the exact directory requested; if you need to enforce that behavior, you can either fail (error) when pwd indicates that you got a different directory, or you may enforce serial execution of this part of the build by some other means such as stage name: '…', concurrency: 1.

If you do not care about locking, just use the dir step to change current directory.