Skip to content

Commit

Permalink
[FIXED JENKINS-14027]
Browse files Browse the repository at this point in the history
  • Loading branch information
ndeloof committed Nov 22, 2012
1 parent f8a524e commit ef1dab2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/groovy/com/cloudbees/plugins/flow/FlowDSL.groovy
Expand Up @@ -35,6 +35,8 @@ import java.util.concurrent.Callable
import static hudson.model.Result.FAILURE
import java.util.concurrent.ExecutionException
import java.util.concurrent.CopyOnWriteArrayList
import hudson.security.ACL
import org.acegisecurity.context.SecurityContextHolder

public class FlowDSL {

Expand Down Expand Up @@ -267,10 +269,15 @@ public class FlowDelegate {

closures.each {closure ->
Closure<FlowState> track_closure = {
flowRun.state = new FlowState(SUCCESS, upstream)
closure()
lastCompleted.addAll(flowRun.state.lastCompleted)
return flowRun.state
def ctx = ACL.impersonate(ACL.SYSTEM)
try {
flowRun.state = new FlowState(SUCCESS, upstream)
closure()
lastCompleted.addAll(flowRun.state.lastCompleted)
return flowRun.state
} finally {
SecurityContextHolder.setContext(ctx)
}
}

tasks.add(pool.submit(track_closure as Callable))
Expand Down

0 comments on commit ef1dab2

Please sign in to comment.