提交 f2b62bc0 编写于 作者: K Kohsuke Kawaguchi

exposing a few more objects that are likely useful.

上级 a1fe8ccd
......@@ -25,7 +25,10 @@ package hudson.cli;
import groovy.lang.GroovyShell;
import groovy.lang.Binding;
import hudson.model.AbstractProject;
import hudson.model.Hudson;
import hudson.model.Item;
import hudson.model.Run;
import hudson.remoting.Callable;
import hudson.AbortException;
import hudson.Extension;
......@@ -71,6 +74,17 @@ public class GroovyCommand extends CLICommand implements Serializable {
Binding binding = new Binding();
binding.setProperty("out",new PrintWriter(stdout,true));
String j = getClientEnvironmentVariable("JOB_NAME");
if (j!=null) {
Item job = Hudson.getInstance().getItemByFullName(j);
binding.setProperty("currentJob", job);
String b = getClientEnvironmentVariable("BUILD_NUMBER");
if (b!=null && job instanceof AbstractProject) {
Run r = ((AbstractProject) job).getBuildByNumber(Integer.parseInt(b));
binding.setProperty("currentBuild", r);
}
}
GroovyShell groovy = new GroovyShell(binding);
groovy.run(loadScript(),"RemoteClass",remaining.toArray(new String[remaining.size()]));
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册