提交 6ce16cbc 编写于 作者: K kohsuke

added script console for slaves


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8208 71c3de6d-444a-0410-be80-ed276b4c234a
上级 9e1ec88a
......@@ -340,6 +340,24 @@ public abstract class Computer extends AbstractModelObject {
w.close();
}
public void doScript( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
// ability to run arbitrary script is dangerous,
// so tie it to the admin access
Hudson.getInstance().checkPermission(Hudson.ADMINISTER);
String text = req.getParameter("script");
if(text!=null) {
try {
req.setAttribute("output",
RemotingDiagnostics.executeGroovy(text,getChannel()));
} catch (InterruptedException e) {
throw new ServletException(e);
}
}
req.getView(this,"_script.jelly").forward(req,rsp);
}
/**
* Gets the current {@link Computer} that the build is running.
* This method only works when called during a build, such as by
......
<!--
Called from doScript() to display the execution result and the form.
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<t:scriptConsole>
<pre>println System.getenv("PATH")</pre>
<p>
This execution happens in the slave agent JVM.
</p>
</t:scriptConsole>
</j:jelly>
......@@ -7,6 +7,7 @@
<l:tasks>
<l:task icon="images/24x24/up.gif" href=".." title="${%Back to List}" />
<l:task icon="images/24x24/notepad.gif" href="${rootURL}/${it.url}/builds" title="${%Build History}" />
<l:task icon="images/24x24/notepad.gif" href="script" title="${%Script Console}" />
</l:tasks>
</l:side-panel>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册