Groovy script defining this workflow. A quick example:

node {
    sh 'echo hello world'
}

You can write any Groovy code you need, using Java API calls plus the GDK. You can also call Jenkins APIs and APIs in Jenkins plugins. (If Use Groovy Sandbox is checked, or you are not an administrator, not all APIs will be available.)

There are many special build steps available, like node and sh in the example. Use the Snippet Generator to see them all and see how they should be configured. Step parameters are given as key-value pairs; if there is just one mandatory parameter the name may be omitted, so

stage 'Build'

is a shortcut for

stage name: 'Build'

but if you specify multiple parameters they must all be named:

stage name: 'Build', concurrency: 1

Environment Variables

A set of environment variables are made available to all Jenkins Job types, including Workflow Jobs. The following is a general list of variables (by name) that are available to all Job types. See the notes below the list for Workflow specific details.

The following variables are currently unavailable inside a workflow script:

Using Environment Variables

Environment variables are injected into scripts through a variable named "env". This variable, like any other variable, can be used in the general flow of the script, or in variable substitutions e.g. when constructing email content when using the mail step:

    mail (to: 'devops@acme.com',
        subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) is waiting for input",
        body: "Please go to ${env.BUILD_URL} and verify the build");

For more on environment variables, see here.

Current build

The currentBuild variable may be used to refer to the currently running build. It is an object similar to that documented for the return value of the build step (when wait is enabled). Additionally, for this build only (but not for other builds), the following properties are writable: