Skip to content

Commit 717df4f

Browse files
committed
Report the failed step name in SynchronousResumeNotSupportedException
1 parent bbb6ce4 commit 717df4f

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/main/java/org/jenkinsci/plugins/workflow/steps/StepContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,9 @@ public boolean hasBody() {
149149
public abstract int hashCode();
150150

151151
private static final long serialVersionUID = 1L;
152+
153+
/**
154+
* Returns the function name used in pipeline Jenkinsfile for the current StepNode.
155+
*/
156+
public abstract String getStepDisplayFunctionName() throws IOException;
152157
}

src/main/java/org/jenkinsci/plugins/workflow/steps/SynchronousNonBlockingStepExecution.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import hudson.util.ClassLoaderSanityThreadFactory;
66
import hudson.util.DaemonThreadFactory;
77
import hudson.util.NamingThreadFactory;
8+
9+
import java.io.IOException;
810
import java.util.concurrent.ExecutorService;
911
import java.util.concurrent.Executors;
1012
import java.util.concurrent.Future;
@@ -72,7 +74,14 @@ public void stop(Throwable cause) throws Exception {
7274

7375
@Override
7476
public void onResume() {
75-
getContext().onFailure(new SynchronousResumeNotSupportedException());
77+
StepContext context = getContext();
78+
String stepFunctionDisplayName = null;
79+
try {
80+
stepFunctionDisplayName = context.getStepDisplayFunctionName();
81+
} catch (IOException x) {
82+
// ignore
83+
}
84+
context.onFailure(new SynchronousResumeNotSupportedException(stepFunctionDisplayName));
7685
}
7786

7887
@Override public @NonNull String getStatus() {

src/main/java/org/jenkinsci/plugins/workflow/steps/SynchronousResumeNotSupportedException.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,18 @@
3333
*/
3434
public class SynchronousResumeNotSupportedException extends Exception {
3535

36+
private static final String message = "Resume after a restart not supported for non-blocking synchronous steps";
37+
3638
public SynchronousResumeNotSupportedException() {
37-
super("Resume after a restart not supported for non-blocking synchronous steps");
39+
super(message);
40+
}
41+
42+
public SynchronousResumeNotSupportedException(String stepDisplayFunctionName) {
43+
super(
44+
stepDisplayFunctionName == null
45+
? message
46+
: message + ", failed step is " + stepDisplayFunctionName + ", you may wrap this block into a retry step "
47+
+ "with nonresumable condition");
3848
}
3949

4050
}

0 commit comments

Comments
 (0)