|
10 | 10 | import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
|
11 | 11 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
12 | 12 | import hudson.Extension;
|
13 |
| -import hudson.model.Build; |
14 | 13 | import hudson.model.Cause;
|
15 | 14 | import hudson.model.CauseAction;
|
| 15 | +import hudson.model.Executor; |
16 | 16 | import hudson.model.Item;
|
17 | 17 | import hudson.model.Job;
|
18 | 18 | import hudson.model.ParameterDefinition;
|
|
21 | 21 | import hudson.model.ParametersDefinitionProperty;
|
22 | 22 | import hudson.model.Queue;
|
23 | 23 | import hudson.model.Result;
|
| 24 | +import hudson.model.Run; |
24 | 25 | import hudson.model.StringParameterValue;
|
25 | 26 | import hudson.model.queue.QueueTaskFuture;
|
26 | 27 | import hudson.model.queue.Tasks;
|
@@ -257,12 +258,12 @@ private void cancelPreviousJobsInQueueThatMatch(@Nonnull StashCause stashCause)
|
257 | 258 |
|
258 | 259 | private void abortRunningJobsThatMatch(@Nonnull StashCause stashCause) {
|
259 | 260 | logger.fine("Looking for running jobs that match PR ID: " + stashCause.getPullRequestId());
|
260 |
| - for (Object o : job.getBuilds()) { |
261 |
| - if (o instanceof Build) { |
262 |
| - Build build = (Build) o; |
263 |
| - if (build.isBuilding() && hasCauseFromTheSamePullRequest(build.getCauses(), stashCause)) { |
264 |
| - logger.info("Aborting build: " + build + " since PR is outdated"); |
265 |
| - build.getExecutor().interrupt(Result.ABORTED); |
| 261 | + for (Run<?, ?> run : job.getBuilds()) { |
| 262 | + if (run.isBuilding() && hasCauseFromTheSamePullRequest(run.getCauses(), stashCause)) { |
| 263 | + logger.info("Aborting build: " + run.getId() + " since PR is outdated"); |
| 264 | + Executor executor = run.getExecutor(); |
| 265 | + if (executor != null) { |
| 266 | + executor.interrupt(Result.ABORTED); |
266 | 267 | }
|
267 | 268 | }
|
268 | 269 | }
|
|
0 commit comments