Unable to rebuild a job triggered by polling
@@ -28,6 +28,7 @@ package hudson.triggers;
import static java.util.logging.Level.WARNING;
import antlr.ANTLRException;
+import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
@@ -711,6 +712,7 @@ public class SCMTrigger extends Trigger<Item> {
* Only used while ths cause is in the queue.
* Once attached to the build, we'll move this into a file to reduce the memory footprint.
*/
+ @CheckForNull
private String pollingLog;
private transient Run run;
@@ -743,7 +745,10 @@ public class SCMTrigger extends Trigger<Item> {
this.run = build;
try {
BuildAction a = new BuildAction(build);
+ // pollingLog can be null when rebuilding a job that was initially triggered by polling.
+ if (pollingLog != null) {
Files.writeString(Util.fileToPath(a.getPollingLogFile()), pollingLog, Charset.defaultCharset());
+ }
build.replaceAction(a);
} catch (IOException e) {
LOGGER.log(WARNING, "Failed to persist the polling log", e);
