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

Merge branch 'pull-535'

......@@ -67,6 +67,9 @@ Upcoming changes</a>
<li class=bug>
Detect bugs relating to short <code>Descriptor</code> names early.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-14995">issue 14995</a> continued)
<li class=rfe>
Allow the user to type in the reason why a node is offline
(<a href="https://github.com/jenkinsci/jenkins/pull/535">pull 535</a>)
<li class=rfe>
Parameters defined in matrix projects are now available in configuration builds.
(<a href="https://github.com/jenkinsci/jenkins/pull/543">pull 543</a>)
......
......@@ -240,6 +240,21 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return offlineCause;
}
/**
* If the computer was offline (either temporarily or not),
* this method will return the cause as a string (without user info).
*
* @return
* null if the system was put offline without given a cause.
*/
@Exported
public String getOfflineCauseReason() {
String newString = offlineCause.toString().replaceAll(
"^Disconnected by [\\w]* \\: ","");
return newString.toString().replaceAll(
"^Disconnected by [\\w]*","");
}
/**
* Gets the channel that can be used to run a program on this computer.
*
......@@ -999,6 +1014,16 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return HttpResponses.redirectToDot();
}
public HttpResponse doChangeOfflineCause(@QueryParameter String offlineMessage) throws IOException, ServletException {
checkPermission(DISCONNECT);
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
setTemporarilyOffline(true,
OfflineCause.create(hudson.slaves.Messages._SlaveComputer_DisconnectedBy(
Jenkins.getAuthentication().getName(),
offlineMessage!=null ? " : " + offlineMessage : "")));
return HttpResponses.redirectToDot();
}
public Api getApi() {
return new Api(this);
}
......
......@@ -36,6 +36,9 @@ THE SOFTWARE.
<form method="post" action="toggleOffline">
<f:submit value="${%submit.temporarilyOffline}" />
</form>
<form method="post" action="setOfflineCause">
<f:submit value="${%submit.updateOfflineCause}" />
</form>
</l:hasPermission>
</j:when>
<j:otherwise>
......
......@@ -22,6 +22,7 @@
submit.temporarilyOffline=Bring this node back online
submit.not.temporarilyOffline=Mark this node temporarily offline
submit.updateOfflineCause=Update offline reason
title.projects_tied_on=Projects tied to {0}
title.no_manual_launch=This node has an availability policy that will "{0}". Currently, this mandates that the node be offline.
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Seiji Sogabe, Stephen Connolly, Tom Huybrechts
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<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" xmlns:i="jelly:fmt">
<l:layout title="${%title(it.displayName)}" norefresh="true">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<l:hasPermission permission="${it.DISCONNECT}">
<h2>${%title(it.displayName)}</h2>
<p>
${%blurb}
</p>
<form method="post" action="changeOfflineCause">
<f:textarea name="offlineMessage" value="${it.getOfflineCauseReason()}"/>
<p>
<f:submit value="${%submit}" />
</p>
</form>
</l:hasPermission>
</l:main-panel>
</l:layout>
</j:jelly>
title=Set {0} Offline Reason
blurb=You can set or update the reason why this node offline, so that others can see why:
submit=Update reason
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册