use of org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamNodeAction in project blueocean-plugin by jenkinsci.
the class DownstreamJobListener method onStarted.
@Override
public void onStarted(Run<?, ?> run, TaskListener listener) {
for (BuildUpstreamNodeAction action : run.getActions(BuildUpstreamNodeAction.class)) {
Run triggerRun = Run.fromExternalizableId(action.getUpstreamRunId());
if (triggerRun instanceof WorkflowRun) {
FlowExecution execution = ((WorkflowRun) triggerRun).getExecution();
FlowNode node;
if (execution == null) {
LOGGER.warning("Could not retrieve upstream FlowExecution");
continue;
}
try {
node = execution.getNode(action.getUpstreamNodeId());
} catch (IOException e) {
LOGGER.warning("Could not retrieve upstream node: " + e);
continue;
}
if (node == null) {
LOGGER.warning("Could not retrieve upstream node (null)");
continue;
}
// Add an action on the triggerRun node pointing to the currently executing run
String description = run.getDescription();
if (description == null) {
description = run.getFullDisplayName();
}
Link link = LinkResolver.resolveLink(run);
if (link != null) {
try {
// Also add to the actual trigger node so we can find it later by step
node.addAction(new NodeDownstreamBuildAction(link, description));
node.save();
} catch (IOException e) {
LOGGER.severe("Could not persist node: " + e);
}
}
}
}
}
Aggregations