Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
660c0f6e
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
660c0f6e
编写于
2月 29, 2012
作者:
K
Kohsuke Kawaguchi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added programmatic config.xml submission/retrieval support.
上级
d9097678
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
9 deletion
+52
-9
changelog.html
changelog.html
+2
-0
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+42
-9
core/src/main/resources/hudson/model/Computer/_api.jelly
core/src/main/resources/hudson/model/Computer/_api.jelly
+8
-0
未找到文件。
changelog.html
浏览文件 @
660c0f6e
...
...
@@ -57,6 +57,8 @@ Upcoming changes</a>
<ul
class=
image
>
<li
class=
bug
>
Fixed NPE in Groovy script execution via CLI (
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-12302"
>
issue 12302
</a>
)
<li
class=
rfe
>
Supported programmatic retrieval/update of slave
<tt>
config.xml
</tt>
<li
class=
rfe
>
Breadcrumb now supports drop-down menu for faster navigation
(
<a
href=
"https://groups.google.com/forum/#!topic/jenkinsci-dev/j9uCKnQB-Xw/discussion"
>
discussion
</a>
)
...
...
core/src/main/java/hudson/model/Computer.java
浏览文件 @
660c0f6e
...
...
@@ -64,6 +64,7 @@ import org.kohsuke.stapler.QueryParameter;
import
org.kohsuke.stapler.HttpResponses
;
import
org.kohsuke.stapler.HttpResponse
;
import
org.kohsuke.stapler.HttpRedirect
;
import
org.kohsuke.stapler.WebMethod
;
import
org.kohsuke.stapler.export.Exported
;
import
org.kohsuke.stapler.export.ExportedBean
;
import
org.kohsuke.args4j.Option
;
...
...
@@ -87,6 +88,8 @@ import java.net.InetAddress;
import
java.net.NetworkInterface
;
import
java.net.Inet4Address
;
import
static
javax
.
servlet
.
http
.
HttpServletResponse
.*;
/**
* Represents the running state of a remote computer that holds {@link Executor}s.
*
...
...
@@ -1069,27 +1072,57 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
String
name
=
Util
.
fixEmptyAndTrim
(
req
.
getSubmittedForm
().
getString
(
"name"
));
Jenkins
.
checkGoodName
(
name
);
final
Jenkins
app
=
Jenkins
.
getInstance
();
Node
result
=
getNode
().
reconfigure
(
req
,
req
.
getSubmittedForm
());
replaceBy
(
result
);
// take the user back to the slave top page.
rsp
.
sendRedirect2
(
"../"
+
result
.
getNodeName
()+
'/'
);
}
/**
* Accepts <tt>config.xml</tt> submission, as well as serve it.
*/
@WebMethod
(
name
=
"config.xml"
)
public
void
doConfigDotXml
(
StaplerRequest
req
,
StaplerResponse
rsp
)
throws
IOException
,
ServletException
{
checkPermission
(
Jenkins
.
ADMINISTER
);
if
(
req
.
getMethod
().
equals
(
"GET"
))
{
// read
rsp
.
setContentType
(
"application/xml"
);
Jenkins
.
XSTREAM2
.
toXML
(
getNode
(),
rsp
.
getOutputStream
());
return
;
}
if
(
req
.
getMethod
().
equals
(
"POST"
))
{
// submission
Node
result
=
(
Node
)
Jenkins
.
XSTREAM2
.
fromXML
(
req
.
getReader
());
replaceBy
(
result
);
return
;
}
// huh?
rsp
.
sendError
(
SC_BAD_REQUEST
);
}
/**
* Replaces the current {@link Node} by another one.
*/
private
void
replaceBy
(
Node
newNode
)
throws
ServletException
,
IOException
{
final
Jenkins
app
=
Jenkins
.
getInstance
();
// replace the old Node object by the new one
synchronized
(
app
)
{
List
<
Node
>
nodes
=
new
ArrayList
<
Node
>(
app
.
getNodes
());
int
i
=
nodes
.
indexOf
(
getNode
());
if
(
i
<
0
)
{
sendError
(
"This slave appears to be removed while you were editing the configuration"
,
req
,
rsp
);
return
;
throw
new
IOException
(
"This slave appears to be removed while you were editing the configuration"
);
}
nodes
.
set
(
i
,
result
);
nodes
.
set
(
i
,
newNode
);
app
.
setNodes
(
nodes
);
}
// take the user back to the slave top page.
rsp
.
sendRedirect2
(
"../"
+
result
.
getNodeName
()+
'/'
);
}
/**
* Really deletes the slave.
*/
...
...
core/src/main/resources/hudson/model/Computer/_api.jelly
浏览文件 @
660c0f6e
...
...
@@ -28,4 +28,12 @@ THE SOFTWARE.
<p>
Load statistics of this computer has <a href="../loadStatistics/api/">its own separate API</a>.
</p>
<h2>Fetch/Update config.xml</h2>
<p>
To programmatically obtain <tt>config.xml</tt>, hit <a href="../config.xml">this URL</a>.
You can also POST an updated <tt>config.xml</tt> to the same URL to programmatically
update the configuration of a node.
</p>
</j:jelly>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录