Skip to content

Commit

Permalink
Merge pull request #394 from kuisathaverat/JENKINS-34369
Browse files Browse the repository at this point in the history
[JENKINS-34369] protect against a NPE form GitSCM.getBuildData
  • Loading branch information
MarkEWaite committed Oct 20, 2016
2 parents fcbdc76 + f88c50d commit 2025127
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -11,6 +11,7 @@
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor;
import hudson.plugins.git.util.Build;
import hudson.plugins.git.util.BuildData;
import hudson.plugins.git.util.GitUtils;
import hudson.plugins.git.util.MergeRecord;
import org.eclipse.jgit.lib.ObjectId;
Expand Down Expand Up @@ -85,7 +86,12 @@ public Revision decorateRevisionToBuild(GitSCM scm, Run<?, ?> build, GitClient g
// record the fact that we've tried building 'rev' and it failed, or else
// BuildChooser in future builds will pick up this same 'rev' again and we'll see the exact same merge failure
// all over again.
scm.getBuildData(build).saveBuild(new Build(marked,rev, build.getNumber(), FAILURE));
BuildData bd = scm.getBuildData(build);
if(bd != null){
bd.saveBuild(new Build(marked,rev, build.getNumber(), FAILURE));
} else {
listener.getLogger().println("Was not possible to get build data");
}
throw new AbortException("Branch not suitable for integration as it does not merge cleanly: " + ex.getMessage());
}

Expand Down

0 comments on commit 2025127

Please sign in to comment.