Skip to content

Commit

Permalink
Merge pull request #11 from jglick/Owner-ACL-JENKINS-34281
Browse files Browse the repository at this point in the history
[JENKINS-34281] More general fix of CpsFlowExecution.suspendAll ACL bug
  • Loading branch information
jglick committed Aug 3, 2016
2 parents e94fd55 + 5c8499e commit baf8f40
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -52,6 +52,7 @@
import hudson.scm.ChangeLogSet;
import hudson.scm.SCM;
import hudson.scm.SCMRevisionState;
import hudson.security.ACL;
import hudson.util.Iterators;
import hudson.util.NullStream;
import hudson.util.PersistedList;
Expand Down Expand Up @@ -83,6 +84,7 @@
import jenkins.model.lazy.BuildReference;
import jenkins.model.lazy.LazyBuildMixIn;
import jenkins.model.queue.AsynchronousExecution;
import jenkins.security.NotReallyRoleSensitiveCallable;
import jenkins.util.Timer;
import org.jenkinsci.plugins.workflow.actions.LogAction;
import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
Expand Down Expand Up @@ -706,11 +708,15 @@ private String key() {
if (candidate != null && candidate.getParent().getFullName().equals(job) && candidate.getId().equals(id)) {
run = candidate;
} else {
Jenkins jenkins = Jenkins.getInstance();
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
throw new IOException("Jenkins is not running"); // do not use Jenkins.getActiveInstance() as that is an ISE
}
WorkflowJob j = jenkins.getItemByFullName(job, WorkflowJob.class);
WorkflowJob j = ACL.impersonate(ACL.SYSTEM, new NotReallyRoleSensitiveCallable<WorkflowJob,IOException>() {
@Override public WorkflowJob call() throws IOException {
return jenkins.getItemByFullName(job, WorkflowJob.class);
}
});
if (j == null) {
throw new IOException("no such WorkflowJob " + job);
}
Expand Down

0 comments on commit baf8f40

Please sign in to comment.