Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-27424] Updated help texts. Added a description for currentJob.
  • Loading branch information
ikedam committed Mar 14, 2015
1 parent 2e5c538 commit ef071a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
Expand Up @@ -6,18 +6,27 @@
<li>When exception occurred or Label Expression is not parsed correctly, builds are canceled.</li>
</ul>
<br>
<p>Following variables are binded, but there may be cases that some type of parameters are not set, or set to wrong value.
<p>Following variables are bound:</p>
<dl>
<dt>currentJob</dt>
<dd>
The job to be built.
For multi-configuration projects, an instance of MatrixProject is passed for a parent build
and an instance of MatrixConfiguration is passed for a child build.
</dd>
</dl>
<p>Additionally, following variables are bound, but there may be cases that some type of parameters are not set, or set to wrong value.
This is for a build is not started yet when this Groovy script is evaluated.</p>
<ul>
<li>Parameters specified in "This build is parameterized"</li>
<li>Axes defined in a matrix project.</li>
<li>Axes defined in a multi-configuration project.</li>
<li>Other variables that plugins create.</li>
</ul>
<br>
<p>Here is an example:</p>
<code style="white-space: pre-wrap;">
Example1-----------------------------------------------------------------------------
// parameters defined in "This build is parameterized" are binded,
// parameters defined in "This build is parameterized" are bound,
// and you can use them just as variables.
if(is_test == "true")
{
Expand All @@ -29,8 +38,8 @@
return null;

Example2-----------------------------------------------------------------------------
// Values defined with axe with a matrix project are also binded.
// But that value is not defined in a root matrix build,
// Values defined with axes with a multi-configuration project are also bound.
// But that value is not defined in a parent build,
// so access with binding.getVariables().get(VARNAME) .
// (accessing VARNAME directly results exceptions)
switch(binding.getVariables().get("target"))
Expand All @@ -44,5 +53,9 @@
// run on Linux.
return "Linux";
}

Example3-----------------------------------------------------------------------------
// Decides the node to run on for its job name.
["win", "linux"].find(currentJob.name.contains(it))
</code>
</div>
Expand Up @@ -6,7 +6,12 @@
<li>例外が発生したり、文字列がラベル式として評価できない場合、ビルドをキャンセルします。</li>
</ul>
<br>
<p>以下の変数をバインドし、Groovyスクリプトからアクセスできるようにします。ただし、特定の変数が設定されなかったり、おかしな値が設定される場合があるかもしれません。
<p>以下の変数が定義されます。</p>
<dl>
<dt>currentJob</dt>
<dd>ビルド対象のジョブ。マトリクス構成プロジェクトの場合、親ビルドには MatrixProject、 子ビルドには MatrixConfiguration のインスタンスが渡されるので注意してください。</dd>
</dl>
<p>また、以下の変数をバインドし、Groovyスクリプトからアクセスできるようにします。ただし、特定の変数が設定されなかったり、おかしな値が設定される場合があるかもしれません。
これはGroovyスクリプトの実行時点で、まだビルドが実際には始まっていないため各種の値の取得処理に制限があるためです。</p>
<ul>
<li>「ビルドのパラメータ化」で指定したパラメータ</li>
Expand Down Expand Up @@ -43,5 +48,9 @@
// run on Linux.
return "Linux";
}

Example3-----------------------------------------------------------------------------
// ジョブの名称から実行するノードを決定します。
["win", "linux"].find(currentJob.name.contains(it))
</code>
</div>

0 comments on commit ef071a8

Please sign in to comment.