Skip to content
Permalink
Browse files
[FIXED JENKINS-18898] ToolInstallation.getHome may be null, and build…
…EnvVars must take that into account.
  • Loading branch information
jglick committed Jul 23, 2013
1 parent e78c541 commit be158b4b2ae269de4a55d04f293c1ec34765e056
@@ -67,6 +67,9 @@
<li class=bug>
Provided maven settings.xml in maven builder is lost.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15976">issue 15976</a>)
<li class=bug>
Exception when running polling with a Maven installation not defined on master.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18898">issue 18898</a>)
<li class=bug>
Since 1.477 GET on <code>/view/…/config.xml</code> included a spurious wrapper element.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-17302">issue 17302</a>)
@@ -105,9 +105,13 @@ public boolean getExists() {
* @deprecated as of 1.460. Use {@link #buildEnvVars(EnvVars)}
*/
public void buildEnvVars(Map<String,String> env) {
String home = getHome();
if (home == null) {
return;
}
// see EnvVars javadoc for why this adds PATH.
env.put("PATH+JDK",getHome()+"/bin");
env.put("JAVA_HOME",getHome());
env.put("PATH+JDK",home+"/bin");
env.put("JAVA_HOME", home);
}

/**
@@ -486,6 +486,9 @@ public File getHomeDir() {
@Override
public void buildEnvVars(EnvVars env) {
String home = getHome();
if (home == null) {
return;
}
env.put("M2_HOME", home);
env.put("MAVEN_HOME", home);
env.put("PATH+MAVEN", home + "/bin");
@@ -32,7 +32,6 @@
import hudson.model.*;
import hudson.slaves.NodeSpecific;
import hudson.util.DescribableList;
import hudson.util.StreamTaskListener;
import hudson.util.XStream2;

import java.io.Serializable;
@@ -41,6 +40,7 @@

import com.thoughtworks.xstream.annotations.XStreamSerializable;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import javax.annotation.CheckForNull;
import jenkins.model.Jenkins;

/**
@@ -125,8 +125,9 @@ public String getName() {
*
* The path can be in Unix format as well as in Windows format.
* Must be absolute.
* @return the home directory location, if defined (may only be defined on the result of {@link #translate(Node, EnvVars, TaskListener)}, e.g. if unavailable on master)
*/
public String getHome() {
public @CheckForNull String getHome() {
return home;
}

@@ -64,8 +64,10 @@
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.HtmlButton;
import hudson.EnvVars;
import hudson.model.FreeStyleBuild;
import hudson.model.PasswordParameterDefinition;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.SingleFileSCM;
import org.jvnet.hudson.test.TestExtension;
@@ -237,4 +239,12 @@ public void testDefaultSettingsProvider() throws Exception {
assertEquals("/tmp/global-settigns.xml", ((FilePathGlobalSettingsProvider)m.getGlobalSettings()).getPath());
}
}

@Bug(18898)
public void testNullHome() throws Exception {
EnvVars env = new EnvVars();
new MavenInstallation("_", "", Collections.<ToolProperty<?>>emptyList()).buildEnvVars(env);
assertEquals("{}", env.toString());
}

}

0 comments on commit be158b4

Please sign in to comment.