Skip to content
Permalink
Browse files

[FIX JENKINS-38615] Add user to restart log message

  • Loading branch information
daniel-beck committed Oct 4, 2016
1 parent 96ec7a2 commit 4462eda829944a39f2ddfdab607d7105be8aface
Showing with 11 additions and 1 deletion.
  1. +11 −1 core/src/main/java/hudson/model/UpdateCenter.java
@@ -30,6 +30,7 @@
import hudson.PluginManager;
import hudson.PluginWrapper;
import hudson.ProxyConfiguration;
import hudson.security.ACLContext;
import jenkins.util.SystemProperties;
import hudson.Util;
import hudson.XmlFile;
@@ -1371,6 +1372,11 @@ public Throwable getError() {
@Exported(inline=true)
public volatile RestartJenkinsJobStatus status = new Pending();

/**
* The name of the user that started this job
*/
private String authentication;

/**
* Cancel job
*/
@@ -1384,6 +1390,7 @@ public synchronized boolean cancel() {

public RestartJenkinsJob(UpdateSite site) {
super(site);
this.authentication = Jenkins.getAuthentication().getName();
}

public synchronized void run() {
@@ -1392,7 +1399,10 @@ public synchronized void run() {
}
status = new Running();
try {
Jenkins.getInstance().safeRestart();
// safeRestart records the current authentication for the log, so set it to the managing user
try (ACLContext _ = ACL.as(User.get(authentication, false, Collections.emptyMap()))) {
Jenkins.getInstance().safeRestart();
}
} catch (RestartNotSupportedException exception) {
// ignore if restart is not allowed
status = new Failure();

0 comments on commit 4462eda

Please sign in to comment.
You can’t perform that action at this time.