Skip to content

Commit

Permalink
Starting to document withEnv.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Mar 27, 2015
1 parent bb86ec9 commit 409beb6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
1 change: 1 addition & 0 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ env.PATH = "${mvnHome}/bin:${env.PATH}"
```

since environment variable overrides are currently limited to being global to a workflow run, not local to the current thread (and thus slave).
You could however use the `withEnv` step (TODO details).

You may also have noticed that we are running `JUnitResultArchiver` several times, something that is not possible in a freestyle project.
The test results recorded in the build are cumulative.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<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.

<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>
</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");
</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>
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,6 @@
</p>
<pre>stage name: 'Build', concurrency: 1</pre>

<h3>Environment Variables</h3>

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.

<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>
</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");
</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>.

<h3>Current build</h3>
<p>
The <code>currentBuild</code> variable may be used to refer to the currently running build.
Expand Down

0 comments on commit 409beb6

Please sign in to comment.