Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
9e39d578
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,发现更多精彩内容 >>
提交
9e39d578
编写于
2月 05, 2020
作者:
D
Daniel Beck
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-21837] Do not record user creating an agent
上级
3b4ac78c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
38 deletion
+18
-38
core/src/main/java/hudson/cli/CreateNodeCommand.java
core/src/main/java/hudson/cli/CreateNodeCommand.java
+0
-5
core/src/main/java/hudson/model/ComputerSet.java
core/src/main/java/hudson/model/ComputerSet.java
+0
-4
core/src/main/java/hudson/model/Slave.java
core/src/main/java/hudson/model/Slave.java
+18
-10
core/src/main/resources/hudson/model/Computer/index.jelly
core/src/main/resources/hudson/model/Computer/index.jelly
+0
-16
test/src/test/java/hudson/cli/CreateNodeCommandTest.java
test/src/test/java/hudson/cli/CreateNodeCommandTest.java
+0
-3
未找到文件。
core/src/main/java/hudson/cli/CreateNodeCommand.java
浏览文件 @
9e39d578
...
...
@@ -63,11 +63,6 @@ public class CreateNodeCommand extends CLICommand {
newNode
.
setNodeName
(
nodeName
);
}
if
(
newNode
instanceof
Slave
)
{
//change userId too
User
user
=
User
.
current
();
((
Slave
)
newNode
).
setUserId
(
user
==
null
?
"anonymous"
:
user
.
getId
());
}
if
(
jenkins
.
getNode
(
newNode
.
getNodeName
())
!=
null
)
{
throw
new
IllegalStateException
(
"Node '"
+
newNode
.
getNodeName
()
+
"' already exists"
);
}
...
...
core/src/main/java/hudson/model/ComputerSet.java
浏览文件 @
9e39d578
...
...
@@ -258,10 +258,6 @@ public final class ComputerSet extends AbstractModelObject implements Describabl
String
xml
=
Jenkins
.
XSTREAM
.
toXML
(
src
);
Node
result
=
(
Node
)
Jenkins
.
XSTREAM
.
fromXML
(
xml
);
result
.
setNodeName
(
name
);
if
(
result
instanceof
Slave
){
//change userId too
User
user
=
User
.
current
();
((
Slave
)
result
).
setUserId
(
user
==
null
?
"anonymous"
:
user
.
getId
());
}
result
.
holdOffLaunchUntilSave
=
true
;
app
.
addNode
(
result
);
...
...
core/src/main/java/hudson/model/Slave.java
浏览文件 @
9e39d578
...
...
@@ -30,6 +30,7 @@ import hudson.EnvVars;
import
hudson.FilePath
;
import
hudson.Launcher
;
import
hudson.Launcher.RemoteLauncher
;
import
hudson.RestrictedSince
;
import
hudson.Util
;
import
hudson.cli.CLI
;
import
hudson.model.Descriptor.FormException
;
...
...
@@ -73,6 +74,7 @@ import jenkins.util.SystemProperties;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.kohsuke.accmod.Restricted
;
import
org.kohsuke.accmod.restrictions.DoNotUse
;
import
org.kohsuke.accmod.restrictions.NoExternalUse
;
import
org.kohsuke.stapler.DataBoundSetter
;
import
org.kohsuke.stapler.HttpResponse
;
...
...
@@ -155,9 +157,10 @@ public abstract class Slave extends Node implements Serializable {
private
transient
volatile
Set
<
Label
>
labels
;
/**
*
Id of user which creates this agent {@link User}
.
*
Removed with no replacement
.
*/
private
String
userId
;
@Deprecated
private
transient
String
userId
;
/**
* Use {@link #Slave(String, String, ComputerLauncher)} and set the rest through setters.
...
...
@@ -204,13 +207,6 @@ public abstract class Slave extends Node implements Serializable {
this
.
nodeProperties
.
replaceBy
(
nodeProperties
);
Slave
node
=
(
Slave
)
Jenkins
.
get
().
getNode
(
name
);
if
(
node
!=
null
){
this
.
userId
=
node
.
getUserId
();
//agent has already existed
}
else
{
User
user
=
User
.
current
();
userId
=
user
!=
null
?
user
.
getId
()
:
"anonymous"
;
}
if
(
name
.
equals
(
""
))
throw
new
FormException
(
Messages
.
Slave_InvalidConfig_NoName
(),
null
);
...
...
@@ -225,13 +221,25 @@ public abstract class Slave extends Node implements Serializable {
* Return id of user which created this agent
*
* @return id of user
*
* @deprecated Removed with no replacement
*/
@Deprecated
@Restricted
(
DoNotUse
.
class
)
@RestrictedSince
(
"TODO"
)
public
String
getUserId
()
{
return
userId
;
}
/**
* This method no longer does anything.
*
* @deprecated Removed with no replacement
*/
@Deprecated
@Restricted
(
DoNotUse
.
class
)
@RestrictedSince
(
"TODO"
)
public
void
setUserId
(
String
userId
){
this
.
userId
=
userId
;
}
public
ComputerLauncher
getLauncher
()
{
...
...
core/src/main/resources/hudson/model/Computer/index.jelly
浏览文件 @
9e39d578
...
...
@@ -71,22 +71,6 @@ THE SOFTWARE.
<p>${%title.no_manual_launch(it.retentionStrategy.descriptor.displayName)}</p>
</j:if>
<!-- Display user which created this node -->
<j:set var="user" value="${app.getUser(it.node.userId)}"/>
<j:if test="${it.node.userId !=null and user!=null}">
<p>
${%Created by}
<j:choose>
<j:when test="${it.node.userId.equals('anonymous')}">
${%anonymous user}
</j:when>
<j:otherwise>
<a href="${app.rootUrl}${user.url}">${user.displayName}</a>
</j:otherwise>
</j:choose>
</p>
</j:if>
<j:if test="${it.node.assignedLabels.size() gt 1}">
<div>
<h2>${%Labels}</h2>
...
...
test/src/test/java/hudson/cli/CreateNodeCommandTest.java
浏览文件 @
9e39d578
...
...
@@ -78,7 +78,6 @@ public class CreateNodeCommandTest {
final
Slave
updatedSlave
=
(
Slave
)
j
.
jenkins
.
getNode
(
"SlaveFromXML"
);
assertThat
(
updatedSlave
.
getNodeName
(),
equalTo
(
"SlaveFromXML"
));
assertThat
(
updatedSlave
.
getNumExecutors
(),
equalTo
(
42
));
assertThat
(
updatedSlave
.
getUserId
(),
equalTo
(
command
.
user
().
getId
()));
}
@Test
public
void
createNodeSpecifyingNameExplicitly
()
throws
Exception
{
...
...
@@ -96,7 +95,6 @@ public class CreateNodeCommandTest {
final
Slave
updatedSlave
=
(
Slave
)
j
.
jenkins
.
getNode
(
"CustomSlaveName"
);
assertThat
(
updatedSlave
.
getNodeName
(),
equalTo
(
"CustomSlaveName"
));
assertThat
(
updatedSlave
.
getNumExecutors
(),
equalTo
(
42
));
assertThat
(
updatedSlave
.
getUserId
(),
equalTo
(
command
.
user
().
getId
()));
}
@Test
public
void
createNodeSpecifyingDifferentNameExplicitly
()
throws
Exception
{
...
...
@@ -116,7 +114,6 @@ public class CreateNodeCommandTest {
final
Slave
updatedSlave
=
(
Slave
)
j
.
jenkins
.
getNode
(
"CustomSlaveName"
);
assertThat
(
updatedSlave
.
getNodeName
(),
equalTo
(
"CustomSlaveName"
));
assertThat
(
updatedSlave
.
getNumExecutors
(),
equalTo
(
42
));
assertThat
(
updatedSlave
.
getUserId
(),
equalTo
(
command
.
user
().
getId
()));
}
@Test
public
void
createNodeShouldFailIfNodeAlreadyExist
()
throws
Exception
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录