diff --git a/src/main/java/hudson/plugins/gearman/SetDescriptionWorker.java b/src/main/java/hudson/plugins/gearman/SetDescriptionWorker.java index 7bb245d..2127092 100644 --- a/src/main/java/hudson/plugins/gearman/SetDescriptionWorker.java +++ b/src/main/java/hudson/plugins/gearman/SetDescriptionWorker.java @@ -20,11 +20,14 @@ package hudson.plugins.gearman; import hudson.model.Run; +import hudson.security.ACL; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.Map; +import org.acegisecurity.context.SecurityContextHolder; +import org.acegisecurity.context.SecurityContext; import org.gearman.client.GearmanJobResult; import org.gearman.client.GearmanJobResultImpl; import org.gearman.worker.AbstractGearmanFunction; @@ -81,11 +84,16 @@ public class SetDescriptionWorker extends AbstractGearmanFunction { // find build then update its description Run build = GearmanPluginUtil.findBuild(jobName, Integer.parseInt(buildNumber)); if (build != null) { + SecurityContext oldContext = ACL.impersonate(ACL.SYSTEM); try { - build.setDescription(buildDescription); - } catch (IOException e) { - throw new IllegalArgumentException("Unable to set description for " + - jobName + ": " + buildNumber); + try { + build.setDescription(buildDescription); + } catch (IOException e) { + throw new IllegalArgumentException("Unable to set description for " + + jobName + ": " + buildNumber); + } + } finally { + SecurityContextHolder.setContext(oldContext); } jobResultMsg = "Description for Jenkins build " +buildNumber+" was updated to " + buildDescription; jobResult = true;