Search in sources :

Example 1 with CpsCompilationErrorsException

use of org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException 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;
    try {
        script = execution.getShell().parse(text);
    } catch (MultipleCompilationErrorsException e) {
        // Convert to a serializable exception, see JENKINS-40109.
        throw new CpsCompilationErrorsException(e);
    }
    // execute body as another thread that shares the same head as this thread
    // as the body can pause.
    cps.newBodyInvoker(t.getGroup().export(script), true).withDisplayName(step.getPath()).withCallback(BodyExecutionCallback.wrap(cps)).start();
    return false;
}
Also used : CpsStepContext(org.jenkinsci.plugins.workflow.cps.CpsStepContext) Script(groovy.lang.Script) CpsCompilationErrorsException(org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException) MultipleCompilationErrorsException(org.codehaus.groovy.control.MultipleCompilationErrorsException) CpsFlowExecution(org.jenkinsci.plugins.workflow.cps.CpsFlowExecution) CpsThread(org.jenkinsci.plugins.workflow.cps.CpsThread)

Aggregations

Script (groovy.lang.Script)1 MultipleCompilationErrorsException (org.codehaus.groovy.control.MultipleCompilationErrorsException)1 CpsCompilationErrorsException (org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException)1 CpsFlowExecution (org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)1 CpsStepContext (org.jenkinsci.plugins.workflow.cps.CpsStepContext)1 CpsThread (org.jenkinsci.plugins.workflow.cps.CpsThread)1