Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-31829 Add currentListener Groovy variable
  • Loading branch information
Fiouz committed Dec 1, 2015
1 parent 61417c7 commit 434ab11
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
Expand Up @@ -140,6 +140,7 @@ public Map<String, String> executeAndGetMapGroovyScript(EnvInjectLogger logger,
groovyShell.setVariable(entryVariable.getKey(), entryVariable.getValue());
}
groovyShell.setVariable("out", logger.getListener().getLogger());
groovyShell.setVariable("currentListener", logger.getListener());

Object groovyResult = groovyShell.evaluate(scriptContent);
if (groovyResult != null && !(groovyResult instanceof Map)) {
Expand Down
Expand Up @@ -26,7 +26,8 @@
This script injects the COMPUTE_VAR environment variable according the CASE parameter value.
<br/>
<br/>
Moreover, 'currentJob' variable and 'currentBuild' variable are available if you want to have an access to the current Job instance and the current Run instance.<br/>
Moreover, 'currentJob' variable, 'currentBuild' variable and 'currentListener' are available if you want to have an access to the current Job instance, the current Run instance
and the current TaskListener instance.<br/>
You are also able to add logging through the 'out' variable.

</p>
Expand Down
Expand Up @@ -80,6 +80,7 @@ public void testBuildInVars() throws Exception {
"def buildNumber1 = env['BUILD_NUMBER']\n" +
"def buildNumber2 = currentBuild.getNumber()\n" +
"def map = [COMPUTE_VAR1: buildNumber1, COMPUTE_VAR2: buildNumber2]\n" +
"assert currentListener instanceof hudson.model.TaskListener;\n" +
"return map");

EnvInjectJobPropertyInfo jobPropertyInfo = new EnvInjectJobPropertyInfo(null, null, null, null, groovyScriptContent.toString(), false);
Expand Down

0 comments on commit 434ab11

Please sign in to comment.