use of org.jenkinsci.plugins.workflow.flow.FlowExecution 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();
}
use of org.jenkinsci.plugins.workflow.flow.FlowExecution in project workflow-job-plugin by jenkinsci.
the class FlowGraphAction method getNodes.
@Exported
public Collection<? extends FlowNode> getNodes() {
FlowExecution exec = run.getExecution();
if (exec == null) {
return Collections.emptySet();
}
List<FlowNode> nodes = new ArrayList<>();
FlowGraphWalker walker = new FlowGraphWalker(exec);
for (FlowNode n : walker) {
nodes.add(n);
}
Collections.reverse(nodes);
return nodes;
}
use of org.jenkinsci.plugins.workflow.flow.FlowExecution in project selenium_java by sergueik.
the class Audit2DbGraphListener method onNewHead.
@Override
public void onNewHead(FlowNode node) {
if (!FlowEndNode.class.isInstance(node)) {
return;
}
LOGGER.fine("Found the FlowEndNode.");
FlowExecution execution = node.getExecution();
LOGGER.fine("FlowExecution.isComplete: " + execution.isComplete());
if (!CpsFlowExecution.class.isInstance(execution)) {
throw new IllegalStateException("Cannot get a pipeline result from a FlowExecution that is not an instance of CpsFlowExecution: " + execution.getClass().getName());
}
CpsFlowExecution cpsFlowExecution = (CpsFlowExecution) execution;
LOGGER.fine("CpsFlowExecution.result: " + cpsFlowExecution.getResult());
BuildDetailsResolver.updateResultAndEndTime(details, cpsFlowExecution, new Date());
LOGGER.fine("Persisting BuildDetails");
repository.saveBuildDetails(details);
LOGGER.fine("Audit2DbGraphListener.onNewHead(): complete");
}
Aggregations