From 36e775876b1658a72cf08757899626f6ef74b2f9 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Mon, 9 Sep 2013 17:19:25 -0400 Subject: [PATCH] =?UTF-8?q?Run.getResult=20may=20be=20null,=20so=20check?= =?UTF-8?q?=20for=20that.=20Observed=20in=201.509.2:=20Parsing=20POMs=20Fa?= =?UTF-8?q?iled=20to=20transfer=20Could=20not=20find=20artifact=20?= =?UTF-8?q?=E2=80=A6=20in=20central=20(http://repo.maven.apache.org/maven2?= =?UTF-8?q?)=20Archiving=20artifacts=20ERROR:=20Processing=20failed=20due?= =?UTF-8?q?=20to=20a=20bug=20in=20the=20code.=20Please=20report=20this=20t?= =?UTF-8?q?o=20jenkinsci-users@googlegroups.com=20java.lang.NullPointerExc?= =?UTF-8?q?eption=20=09at=20hudson.tasks.ArtifactArchiver.perform(Artifact?= =?UTF-8?q?Archiver.java:138)=20=09at=20org.zeroturnaround.jenkins.LiveReb?= =?UTF-8?q?elDeployBuilder.getArtificatOrMetadata(LiveRebelDeployBuilder.j?= =?UTF-8?q?ava:194)=20=09at=20org.zeroturnaround.jenkins.LiveRebelDeployBu?= =?UTF-8?q?ilder.uploadConfiguration(LiveRebelDeployBuilder.java:171)=20?= =?UTF-8?q?=09at=20org.zeroturnaround.jenkins.LiveRebelDeployBuilder.perfo?= =?UTF-8?q?rm(LiveRebelDeployBuilder.java:108)=20=09at=20hudson.tasks.Buil?= =?UTF-8?q?dStepMonitor$1.perform(BuildStepMonitor.java:19)=20=09at=20huds?= =?UTF-8?q?on.model.AbstractBuild$AbstractBuildExecution.perform(AbstractB?= =?UTF-8?q?uild.java:812)=20=09at=20hudson.maven.MavenModuleSetBuild$Maven?= =?UTF-8?q?ModuleSetBuildExecution.build(MavenModuleSetBuild.java:828)=20?= =?UTF-8?q?=09at=20hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExe?= =?UTF-8?q?cution.doRun(MavenModuleSetBuild.java:779)=20=09at=20hudson.mod?= =?UTF-8?q?el.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:?= =?UTF-8?q?594)=20=09at=20hudson.model.Run.execute(Run.java:1575)=20=09at?= =?UTF-8?q?=20hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.jav?= =?UTF-8?q?a:485)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/main/java/hudson/model/Run.java | 3 ++- core/src/main/java/hudson/tasks/ArtifactArchiver.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 49a551be39..eb2f44d6b1 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -400,9 +400,10 @@ public abstract class Run ,RunT extends Run * When a build is {@link #isBuilding() in progress}, this method * returns an intermediate result. + * @return The status of the build, if it has completed or some build step has set a status; may be null if the build is ongoing. */ @Exported - public Result getResult() { + public @CheckForNull Result getResult() { return result; } diff --git a/core/src/main/java/hudson/tasks/ArtifactArchiver.java b/core/src/main/java/hudson/tasks/ArtifactArchiver.java index 5f47ce243f..020ce12647 100644 --- a/core/src/main/java/hudson/tasks/ArtifactArchiver.java +++ b/core/src/main/java/hudson/tasks/ArtifactArchiver.java @@ -135,7 +135,8 @@ public class ArtifactArchiver extends Recorder { String artifacts = build.getEnvironment(listener).expand(this.artifacts); if(ws.copyRecursiveTo(artifacts,excludes,new FilePath(dir))==0) { - if(build.getResult().isBetterOrEqualTo(Result.UNSTABLE)) { + Result result = build.getResult(); + if (result != null && result.isBetterOrEqualTo(Result.UNSTABLE)) { // If the build failed, don't complain that there was no matching artifact. // The build probably didn't even get to the point where it produces artifacts. listenerWarnOrError(listener, Messages.ArtifactArchiver_NoMatchFound(artifacts)); -- GitLab