diff --git a/src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java b/src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java index eab9dc96..e047874a 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepExecution.java @@ -429,6 +429,7 @@ public String getCookie() { return j.getNode(label); } + @Deprecated @Override public boolean isBuildBlocked() { return false; } @@ -535,6 +536,10 @@ public String getShortDescription() { return hasPermission(Item.CANCEL); } + /** + * @deprecated use {@link #getOwnerExecutable} (which does not require a dependency on this plugin) if your core dep is 2.389+ + */ + @Deprecated public @CheckForNull Run run() { try { if (!context.isReady()) { @@ -548,6 +553,10 @@ public String getShortDescription() { } } + /** + * @deprecated use {@link #getOwnerExecutable} (which does not require a dependency on this plugin) if your core dep is 2.389+ + */ + @Deprecated public @CheckForNull Run runForDisplay() { Run r = run(); if (r == null && /* not stored prior to 1.13 */runId != null) { @@ -560,6 +569,12 @@ public String getShortDescription() { return r; } + // TODO 2.389+ @Override + public @CheckForNull Queue.Executable getOwnerExecutable() { + Run r = runForDisplay(); + return r instanceof Queue.Executable ? (Queue.Executable) r : null; + } + @Exported @Override public String getUrl() { // TODO ideally this would be found via FlowExecution.owner.executable, but how do we check for something with a URL? There is no marker interface for it: JENKINS-26091 @@ -721,7 +736,7 @@ private String computeEnclosingLabel(FlowNode executorStepNode, List h } @Override public long getEstimatedDuration() { - Run r = run(); + Run r = runForDisplay(); // Not accurate if there are multiple agents in one build, but better than nothing: return r != null ? r.getEstimatedDuration() : -1; } @@ -995,12 +1010,7 @@ private final class PlaceholderExecutable implements ContinuableExecutable, Acce } @Override public Queue.Executable getParentExecutable() { - Run b = runForDisplay(); - if (b instanceof Queue.Executable) { - return (Queue.Executable) b; - } else { - return null; - } + return getOwnerExecutable(); } @Exported diff --git a/src/test/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepTest.java b/src/test/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepTest.java index 61dc295b..25d29f17 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/support/steps/ExecutorStepTest.java @@ -613,6 +613,8 @@ private static void assertLogMatches(WorkflowRun build, String regexp) throws IO Queue.Item[] items = Queue.getInstance().getItems(); assertEquals(1, items.length); assertEquals(p, items[0].task.getOwnerTask()); + // // TODO 2.389+ remove cast + assertEquals(b, ((ExecutorStepExecution.PlaceholderTask) items[0].task).getOwnerExecutable()); assertEquals(items[0], QueueItemAction.getQueueItem(executorStartNode)); assertTrue(Queue.getInstance().cancel(items[0]));