Skip to content

Commit

Permalink
[FIXED JENKINS-33005] Make StageStepExecution defensively call isRead…
Browse files Browse the repository at this point in the history
…y on foreign builds.

Also make CpsFlowExecution.onLoad unconditionally set programPromise, in case CpsStepContext.getThreadGroupSynchronously is waiting for it.
Originally-Committed-As: 0b4c317b7bc610283be00fef18b796a43315454c
  • Loading branch information
jglick committed Feb 17, 2016
1 parent d5c3b42 commit 7160487
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -11,7 +11,6 @@
import hudson.model.listeners.RunListener;
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -222,18 +221,26 @@ private static void cleanUp(Job<?,?> job, String jobName) {
}

private static void println(StepContext context, String message) {
if (!context.isReady()) {
LOGGER.log(Level.FINE, "cannot print message ‘{0}’ to dead {1}", new Object[] {message, context});
return;
}
try {
context.get(TaskListener.class).getLogger().println(message);
} catch (Exception x) {
LOGGER.log(WARNING, null, x);
LOGGER.log(WARNING, "failed to print message to dead " + context, x);
}
}

// TODO record the stage it got to and display that
private static void cancel(StepContext context, StepContext newer) throws IOException, InterruptedException {
println(context, "Canceled since " + newer.get(Run.class).getDisplayName() + " got here");
println(newer, "Canceling older " + context.get(Run.class).getDisplayName());
context.onFailure(new FlowInterruptedException(Result.NOT_BUILT, new CanceledCause(newer.get(Run.class))));
if (context.isReady()) {
context.onFailure(new FlowInterruptedException(Result.NOT_BUILT, new CanceledCause(newer.get(Run.class))));
} else {
LOGGER.log(WARNING, "cannot cancel dead {0}", context);
}
}

/**
Expand Down

0 comments on commit 7160487

Please sign in to comment.