Skip to content

Commit

Permalink
[FIXED JENKINS-18804] Fixed NPE on TriggeredBuildSelector when the up…
Browse files Browse the repository at this point in the history
…stream is removed.
  • Loading branch information
ikedam committed Sep 29, 2014
1 parent 7243590 commit 0af0734
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -23,6 +23,9 @@
*/
package hudson.plugins.copyartifact;

import java.util.logging.Level;
import java.util.logging.Logger;

import jenkins.model.Jenkins;
import hudson.EnvVars;
import hudson.Extension;
Expand All @@ -44,6 +47,7 @@
* @author Alan Harder
*/
public class TriggeredBuildSelector extends BuildSelector {
private static final Logger LOGGER = Logger.getLogger(TriggeredBuildSelector.class.getName());
/**
* Which build should be used if triggered by multiple upstream builds.
*
Expand Down Expand Up @@ -160,6 +164,14 @@ public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter, Run<?,?>
} else {
// Figure out the parent job and do a recursive call to getBuild
Job<?,?> parentJob = Jenkins.getInstance().getItemByFullName(upstreamProject, Job.class);
if (parentJob == null) {
LOGGER.log(Level.WARNING, "Upstream project doesn't exist (may be removed): {0}", upstreamProject);
continue;
}
if (parentJob.getBuildByNumber(upstreamBuild) == null) {
LOGGER.log(Level.WARNING, "Upstream build doesn't exist (may be removed): {0} #{1}", new Object[]{upstreamProject, upstreamBuild});
continue;
}
Run<?,?> run = getBuild(
job,
env,
Expand Down

0 comments on commit 0af0734

Please sign in to comment.