use of org.jenkinsci.plugins.workflow.flow.FlowDefinition in project workflow-job-plugin by jenkinsci.
the class WorkflowRun method run.
/**
* Actually executes the workflow.
*/
@Override
public void run() {
if (!firstTime) {
throw sleep();
}
try {
onStartBuilding();
OutputStream logger = new FileOutputStream(getLogFile());
listener = new StreamBuildListener(logger, Charset.defaultCharset());
listener.started(getCauses());
Authentication auth = Jenkins.getAuthentication();
if (!auth.equals(ACL.SYSTEM)) {
String name = auth.getName();
if (!auth.equals(Jenkins.ANONYMOUS)) {
name = ModelHyperlinkNote.encodeTo(User.get(name));
}
listener.getLogger().println(hudson.model.Messages.Run_running_as_(name));
}
RunListener.fireStarted(this, listener);
updateSymlinks(listener);
FlowDefinition definition = getParent().getDefinition();
if (definition == null) {
throw new AbortException("No flow definition, cannot run");
}
Owner owner = new Owner(this);
FlowExecution newExecution = definition.create(owner, listener, getAllActions());
boolean loggedHintOverride = false;
if (getParent().isResumeBlocked()) {
if (newExecution instanceof BlockableResume) {
((BlockableResume) newExecution).setResumeBlocked(true);
listener.getLogger().println("Resume disabled by user, switching to high-performance, low-durability mode.");
loggedHintOverride = true;
}
}
if (!loggedHintOverride) {
// Avoid double-logging
listener.getLogger().println("Running in Durability level: " + DurabilityHintProvider.suggestedFor(this.project));
}
FlowExecutionList.get().register(owner);
newExecution.addListener(new GraphL());
completed = new AtomicBoolean();
logsToCopy = new ConcurrentSkipListMap<>();
execution = newExecution;
newExecution.start();
executionPromise.set(newExecution);
FlowExecutionListener.fireRunning(execution);
} catch (Throwable x) {
// ensures isInProgress returns false
execution = null;
finish(Result.FAILURE, x);
try {
executionPromise.setException(x);
} catch (Error e) {
if (e != x) {
// cf. CpsThread.runNextChunk
throw e;
}
}
return;
}
throw sleep();
}
Aggregations