|  | 
| 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; | 
| @@ -258,12 +259,12 @@ private void cancelPreviousJobsInQueueThatMatch(@Nonnull StashCause stashCause) | 
| 258 | 259 | 
 | 
| 259 | 260 |   private void abortRunningJobsThatMatch(@Nonnull StashCause stashCause) { | 
| 260 | 261 |     logger.fine("Looking for running jobs that match PR ID: " + stashCause.getPullRequestId()); | 
| 261 |  | -    for (Object o : job.getBuilds()) { | 
| 262 |  | -      if (o instanceof Build) { | 
| 263 |  | -        Build build = (Build) o; | 
| 264 |  | -        if (build.isBuilding() && hasCauseFromTheSamePullRequest(build.getCauses(), stashCause)) { | 
| 265 |  | -          logger.info("Aborting build: " + build + " since PR is outdated"); | 
| 266 |  | -          build.getExecutor().interrupt(Result.ABORTED); | 
|  | 262 | +    for (Run<?, ?> run : job.getBuilds()) { | 
|  | 263 | +      if (run.isBuilding() && hasCauseFromTheSamePullRequest(run.getCauses(), stashCause)) { | 
|  | 264 | +        logger.info("Aborting build: " + run.getId() + " since PR is outdated"); | 
|  | 265 | +        Executor executor = run.getExecutor(); | 
|  | 266 | +        if (executor != null) { | 
|  | 267 | +          executor.interrupt(Result.ABORTED); | 
| 267 | 268 |         } | 
| 268 | 269 |       } | 
| 269 | 270 |     } | 
|  | 
0 commit comments