Search in sources :

Example 1 with BodyExecution

use of org.jenkinsci.plugins.workflow.steps.BodyExecution 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;
}
Also used : CpsStepContext(org.jenkinsci.plugins.workflow.cps.CpsStepContext) BodyExecution(org.jenkinsci.plugins.workflow.steps.BodyExecution) Closure(groovy.lang.Closure) ResultHandler(org.jenkinsci.plugins.workflow.cps.steps.ParallelStep.ResultHandler) CpsThread(org.jenkinsci.plugins.workflow.cps.CpsThread)

Aggregations

Closure (groovy.lang.Closure)1 CpsStepContext (org.jenkinsci.plugins.workflow.cps.CpsStepContext)1 CpsThread (org.jenkinsci.plugins.workflow.cps.CpsThread)1 ResultHandler (org.jenkinsci.plugins.workflow.cps.steps.ParallelStep.ResultHandler)1 BodyExecution (org.jenkinsci.plugins.workflow.steps.BodyExecution)1