Skip to content

Commit

Permalink
Merge pull request #11 from ndeloof/master
Browse files Browse the repository at this point in the history
fix JENKINS-16047
  • Loading branch information
ndeloof committed Mar 1, 2013
2 parents fc9702b + 3db125c commit a8455c1
Showing 1 changed file with 6 additions and 5 deletions.
Expand Up @@ -4,6 +4,7 @@
import hudson.model.TaskListener;
import hudson.remoting.DelegatingCallable;

import java.io.PrintStream;
import java.io.PrintWriter;

import jenkins.model.Jenkins;
Expand Down Expand Up @@ -41,22 +42,22 @@ public Object call() throws RuntimeException {
if (cl == null) {
cl = Thread.currentThread().getContextClassLoader();
}
PrintWriter pw = new PrintWriter(listener.getLogger());
PrintStream logger = listener.getLogger();
GroovyShell shell = new GroovyShell(cl);

for (Parameter param : parameters) {
final String paramName = param.getName();
if (PW_PARAM_VARIABLE.equals(paramName)) {
pw.write(Messages.skipParamter(PW_PARAM_VARIABLE));
logger.println(Messages.skipParamter(PW_PARAM_VARIABLE));
} else {
shell.setVariable(paramName, param.getValue());
}
}
shell.setVariable(PW_PARAM_VARIABLE, listener.getLogger());
shell.setVariable(PW_PARAM_VARIABLE, logger);
try {
Object output = shell.evaluate(script);
if (output != null) {
pw.println(Messages.resultPrefix() + " " + output);
logger.println(Messages.resultPrefix() + " " + output);
return output;
} else {
return "";
Expand All @@ -65,7 +66,7 @@ public Object call() throws RuntimeException {
if (failWithException) {
throw new ScriptlerExecutionException(t);
}
t.printStackTrace(pw);
t.printStackTrace(logger);
return Boolean.FALSE;
}
}
Expand Down

0 comments on commit a8455c1

Please sign in to comment.