use of org.jenkinsci.plugins.workflow.cps.CpsStepContext in project workflow-cps-plugin by jenkinsci.
the class ParallelStepExecution method start.
@Override
public boolean start() throws Exception {
CpsStepContext cps = (CpsStepContext) getContext();
if (parallelStep.closures.isEmpty()) {
cps.get(TaskListener.class).getLogger().println("No branches to run");
cps.onSuccess(Collections.<String, Object>emptyMap());
return true;
}
CpsThread t = CpsThread.current();
ResultHandler r = new ResultHandler(cps, this, parallelStep.isFailFast());
for (Entry<String, Closure> e : parallelStep.closures.entrySet()) {
BodyExecution body = cps.newBodyInvoker(t.getGroup().export(e.getValue())).withStartAction(new ParallelLabelAction(e.getKey())).withCallback(r.callbackFor(e.getKey())).start();
bodies.add(body);
}
return false;
}
use of org.jenkinsci.plugins.workflow.cps.CpsStepContext in project workflow-cps-plugin by jenkinsci.
the class LoadStepExecution method start.
@Override
public boolean start() throws Exception {
CpsStepContext cps = (CpsStepContext) getContext();
CpsThread t = CpsThread.current();
CpsFlowExecution execution = t.getExecution();
String text = cwd.child(step.getPath()).readToString();
String clazz = execution.getNextScriptName(step.getPath());
String newText = ReplayAction.replace(execution, clazz);
if (newText != null) {
listener.getLogger().println("Replacing Groovy text with edited version");
text = newText;
}
Script script = execution.getShell().parse(text);
// execute body as another thread that shares the same head as this thread
// as the body can pause.
cps.newBodyInvoker(t.getGroup().export(script)).withDisplayName(step.getPath()).withCallback(BodyExecutionCallback.wrap(cps)).start();
return false;
}
Aggregations