diff --git a/pom.xml b/pom.xml index fb0fa20d..e885c484 100644 --- a/pom.xml +++ b/pom.xml @@ -92,6 +92,7 @@ org.jenkins-ci.plugins.workflow workflow-api + 1236.vb_763772ecd87 org.jenkins-ci.plugins.workflow diff --git a/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java b/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java index 56cea822..ee135f7b 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java @@ -86,6 +86,8 @@ import java.util.logging.Logger; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import java.io.Closeable; +import java.io.InterruptedIOException; import jenkins.model.CauseOfInterruption; import jenkins.model.Jenkins; import jenkins.model.lazy.BuildReference; @@ -1080,7 +1082,23 @@ private final class GraphL implements GraphListener { */ private final class NodePrintListener implements GraphListener.Synchronous { @Override public void onNewHead(FlowNode node) { - NewNodeConsoleNote.print(node, getListener()); + // TODO: Breaks show/hide links in the console because the line with the show/hide link gets hidden. + LogStorage storage = LogStorage.of(asFlowExecutionOwner()); + try { + TaskListener listener = TaskListenerDecorator.apply(storage.nodeListener(node), asFlowExecutionOwner(), null); + try { + NewNodeConsoleNote.print(node, listener); + } finally { + if (listener instanceof Closeable) { + ((Closeable) listener).close(); + } + } + } catch (InterruptedIOException | InterruptedException e) { + Thread.currentThread().interrupt(); + LOGGER.log(Level.FINE, e, () -> "Unable to write NewNodeConsoleNote for node " + node.getId()); + } catch (IOException e) { + LOGGER.log(Level.FINE, e, () -> "Unable to write NewNodeConsoleNote for node " + node.getId()); + } } } diff --git a/src/main/java/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote.java b/src/main/java/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote.java index 5cc0ca0a..0d4d5b1b 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/job/console/NewNodeConsoleNote.java @@ -60,7 +60,7 @@ * @see LogStorage#startStep */ @Restricted(NoExternalUse.class) -public class NewNodeConsoleNote extends ConsoleNote { +public class NewNodeConsoleNote extends ConsoleNote { private static final Logger LOGGER = Logger.getLogger(NewNodeConsoleNote.class.getName()); @@ -98,7 +98,7 @@ private NewNodeConsoleNote(FlowNode node) { } @Override - public ConsoleAnnotator annotate(WorkflowRun context, MarkupText text, int charPos) { + public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) { try { StringBuilder startTag = startTagFor(context, id, start, enclosing); text.addMarkup(0, text.length(), startTag.toString(), ""); @@ -109,7 +109,7 @@ public ConsoleAnnotator annotate(WorkflowRun context, MarkupText text, int ch } @Restricted(NoExternalUse.class) - public static StringBuilder startTagFor(@NonNull WorkflowRun context, @NonNull String id, @CheckForNull String start, @CheckForNull String enclosing) { + public static StringBuilder startTagFor(@NonNull Object context, @NonNull String id, @CheckForNull String start, @CheckForNull String enclosing) { StringBuilder startTag = new StringBuilder("[Pipeline] hyperlink\nRunning inside [Pipeline] hyperlink\nRunning inside { start = System.nanoTime(); length = la.getLogText().length(); System.out.printf("Took %dms to compute length of one short node%n", (System.nanoTime() - start) / 1000 / 1000); - assertThat(length, lessThan(50L)); + assertThat(length, lessThan(350L)); } @Ignore("Currently not asserting anything, just here for interactive evaluation.")