提交 9e39d578 编写于 作者: D Daniel Beck

[JENKINS-21837] Do not record user creating an agent

上级 3b4ac78c
......@@ -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");
}
......
......@@ -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);
......
......@@ -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() {
......
......@@ -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>
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册