forked from jenkinsci/pipeline-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
46 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 32 additions & 25 deletions
57
basic-steps/src/main/resources/org/jenkinsci/plugins/workflow/steps/EnvStep/help.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,44 @@ | ||
<div> | ||
Sets one or more environment variables within a block. | ||
This is a more robust way of setting variables than setting values of <code>env.NAME</code>. | ||
<p>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. | ||
These are available to any external processes spawned within that scope. | ||
For example: | ||
<p><pre> | ||
node { | ||
withEnv(['MYTOOL_HOME=/usr/local/mytool']) { | ||
sh '$MYTOOL_HOME/bin/start' | ||
} | ||
} | ||
</pre> | ||
<p>(Note that here we are using single quotes in Groovy, so the variable expansion is being done by the Bourne shell, not Jenkins.) | ||
<p>From Groovy code inside the block, the value is also accessible as <code>env.VARNAME</code>. | ||
You can write to this property rather than using the <code>withEnv</code> step, | ||
though any changes are global to the workflow build so should not include node-specific content such as file paths: | ||
<p><pre> | ||
env.MYTOOL_VERSION = '1.33' | ||
node { | ||
sh '/usr/local/mytool-$MYTOOL_VERSION/bin/start' | ||
} | ||
</pre> | ||
<p>A set of environment variables are made available to all Jenkins projects, including workflows. | ||
The following is a general list of variables (by name) that are available; | ||
see the notes below the list for Workflow-specific details. | ||
|
||
<p> | ||
<iframe src="${rootURL}/env-vars.html" width="100%"></iframe> | ||
</p> | ||
|
||
The following variables are currently unavailable inside a workflow script: | ||
<ul> | ||
<li>EXECUTOR_NUMBER</li> | ||
<li>NODE_NAME</li> | ||
<li>NODE_LABELS</li> | ||
<li>WORKSPACE</li> | ||
<li><code>EXECUTOR_NUMBER</code></li> | ||
<li><code>NODE_NAME</code></li> | ||
<li><code>NODE_LABELS</code></li> | ||
<li><code>WORKSPACE</code></li> | ||
<li>SCM-specific variables such as <code>SVN_REVISION</code><li> | ||
</ul> | ||
|
||
<h4>Using Environment Variables</h4> | ||
|
||
Environment variables are injected into scripts through a variable named "<strong>env</strong>". 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 <code>mail</code> step: | ||
|
||
<p/> | ||
<pre> | ||
mail (to: '[email protected]', | ||
subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) is waiting for input", | ||
body: "Please go to ${env.BUILD_URL} and verify the build"); | ||
As an example of loading variable values from Groovy: | ||
<p><pre> | ||
mail to: '[email protected]', | ||
subject: "Job '${env.JOB_NAME}' (${env.BUILD_NUMBER}) is waiting for input", | ||
body: "Please go to ${env.BUILD_URL} and verify the build" | ||
</pre> | ||
|
||
<p/> | ||
For more on environment variables, | ||
<a href="https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md#managing-the-environment" target="_blank">see | ||
here</a>. | ||
</div> |