Skip to content
Browse files
Merge pull request #394 from kuisathaverat/JENKINS-34369
[JENKINS-34369] protect against a NPE form GitSCM.getBuildData
  • Loading branch information
MarkEWaite committed Oct 20, 2016
2 parents fcbdc76 + f88c50d commit 2025127d7e82cc61b0b8f6ede91997c28bfd3c3d
Showing 1 changed file with 7 additions and 1 deletion.
@@ -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;
@@ -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());

0 comments on commit 2025127

Please sign in to comment.