use of com.cloudbees.groovy.cps.sandbox.DefaultInvoker in project workflow-cps-plugin by jenkinsci.
the class CpsFlowExecution method start.
@Override
public void start() throws IOException {
final CpsScript s = parseScript();
scriptClass = s.getClass();
s.$initialize();
final FlowHead h = new FlowHead(this);
synchronized (this) {
heads.put(h.getId(), h);
}
h.newStartNode(new FlowStartNode(this, iotaStr()));
final CpsThreadGroup g = new CpsThreadGroup(this);
g.register(s);
final SettableFuture<CpsThreadGroup> f = SettableFuture.create();
programPromise = f;
// Ensures we've saves the WorkFlowRun at least once with initial state
saveOwner();
g.runner.submit(new Runnable() {
@Override
public void run() {
CpsThread t = g.addThread(new Continuable(s, createInitialEnv()), h, null);
t.resume(new Outcome(null, null));
f.set(g);
}
/**
* Environment to start executing the script in.
* During sandbox execution, we need to call sandbox interceptor while executing asynchronous code.
*/
private Env createInitialEnv() {
return Envs.empty(isSandbox() ? new SandboxInvoker() : new DefaultInvoker());
}
});
}
Aggregations