diff --git a/core/src/main/java/hudson/Main.java b/core/src/main/java/hudson/Main.java index 89ad4b9076abb253b36e433b94a2f610a70197d3..769f830369f5fc710e61f177712d6144cee22d97 100644 --- a/core/src/main/java/hudson/Main.java +++ b/core/src/main/java/hudson/Main.java @@ -64,7 +64,7 @@ public class Main { public static int run(String[] args) throws Exception { String home = getHudsonHome(); if (home==null) { - System.err.println("HUDSON_HOME is not set."); + System.err.println("JENKINS_HOME is not set."); return -1; } if (args.length < 2) { @@ -76,7 +76,9 @@ public class Main { } private static String getHudsonHome() { - return EnvVars.masterEnvVars.get("HUDSON_HOME"); + String home = EnvVars.masterEnvVars.get("JENKINS_HOME"); + if (home!=null) return home; + return EnvVars.masterEnvVars.get("JENKINS_HOME"); } /** diff --git a/core/src/main/java/hudson/WebAppMain.java b/core/src/main/java/hudson/WebAppMain.java index cab42133d4978ac81b86efda41899a905058f1d8..3e226c019e05b7141fedc5c21cfb309416a306b2 100644 --- a/core/src/main/java/hudson/WebAppMain.java +++ b/core/src/main/java/hudson/WebAppMain.java @@ -261,36 +261,46 @@ public final class WebAppMain implements ServletContextListener { } /** - * Determines the home directory for Hudson. + * Determines the home directory for Jenkins. * + *

+ * We look for a setting that affects the smallest scope first, then bigger ones later. + * + *

* People makes configuration mistakes, so we are trying to be nice * with those by doing {@link String#trim()}. */ private File getHomeDir(ServletContextEvent event) { // check JNDI for the home directory first - try { - InitialContext iniCtxt = new InitialContext(); - Context env = (Context) iniCtxt.lookup("java:comp/env"); - String value = (String) env.lookup("HUDSON_HOME"); - if(value!=null && value.trim().length()>0) - return new File(value.trim()); - // look at one more place. See issue #1314 - value = (String) iniCtxt.lookup("HUDSON_HOME"); - if(value!=null && value.trim().length()>0) - return new File(value.trim()); - } catch (NamingException e) { - // ignore + for (String name : HOME_NAMES) { + try { + InitialContext iniCtxt = new InitialContext(); + Context env = (Context) iniCtxt.lookup("java:comp/env"); + String value = (String) env.lookup(name); + if(value!=null && value.trim().length()>0) + return new File(value.trim()); + // look at one more place. See issue #1314 + value = (String) iniCtxt.lookup(name); + if(value!=null && value.trim().length()>0) + return new File(value.trim()); + } catch (NamingException e) { + // ignore + } + } + + // next the system property + for (String name : HOME_NAMES) { + String sysProp = System.getProperty(name); + if(sysProp!=null) + return new File(sysProp.trim()); } - // finally check the system property - String sysProp = System.getProperty("HUDSON_HOME"); - if(sysProp!=null) - return new File(sysProp.trim()); - // look at the env var next - String env = EnvVars.masterEnvVars.get("HUDSON_HOME"); - if(env!=null) - return new File(env.trim()).getAbsoluteFile(); + for (String name : HOME_NAMES) { + String env = EnvVars.masterEnvVars.get(name); + if(env!=null) + return new File(env.trim()).getAbsoluteFile(); + } // otherwise pick a place by ourselves @@ -304,8 +314,11 @@ public final class WebAppMain implements ServletContextListener { return ws; } - // if for some reason we can't put it within the webapp, use home directory. - return new File(new File(System.getProperty("user.home")),".hudson"); + File legacyHome = new File(new File(System.getProperty("user.home")), ".hudson"); + if (legacyHome.exists()) + return legacyHome; // before rename, this is where it was stored + + return new File(new File(System.getProperty("user.home")), ".jenkins"); } public void contextDestroyed(ServletContextEvent event) { @@ -320,4 +333,6 @@ public final class WebAppMain implements ServletContextListener { private static final Logger LOGGER = Logger.getLogger(WebAppMain.class.getName()); + + private static final String[] HOME_NAMES = {"JENKINS_HOME","HUDSON_HOME"}; } diff --git a/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java b/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java index 5f101d91e5f75d66b5a08d9f507dd524c5ec4490..10723c7da66a3cbabc90efca7d357e3d6ab3fecd 100644 --- a/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java +++ b/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageChecker.java @@ -31,7 +31,7 @@ import org.jvnet.animal_sniffer.IgnoreJRERequirement; import java.util.logging.Logger; /** - * Periodically checks the disk usage of HUDSON_HOME, + * Periodically checks the disk usage of JENKINS_HOME, * and activate {@link HudsonHomeDiskUsageMonitor} if necessary. * * @author Kohsuke Kawaguchi @@ -49,12 +49,12 @@ public class HudsonHomeDiskUsageChecker extends PeriodicWork { long total = Hudson.getInstance().getRootDir().getTotalSpace(); if(free<=0 || total<=0) { // information unavailable. pointless to try. - LOGGER.info("HUDSON_HOME disk usage information isn't available. aborting to monitor"); + LOGGER.info("JENKINS_HOME disk usage information isn't available. aborting to monitor"); cancel(); return; } - LOGGER.fine("Monitoring disk usage of HUDSON_HOME. total="+total+" free="+free); + LOGGER.fine("Monitoring disk usage of JENKINS_HOME. total="+total+" free="+free); // if it's more than 90% full and less than the minimum, activate @@ -63,7 +63,7 @@ public class HudsonHomeDiskUsageChecker extends PeriodicWork { HudsonHomeDiskUsageMonitor.get().activated = (total/free>10 && free< FREE_SPACE_THRESHOLD); } catch (LinkageError _) { // pre Mustang - LOGGER.info("Not on JDK6. Cannot monitor HUDSON_HOME disk usage"); + LOGGER.info("Not on JDK6. Cannot monitor JENKINS_HOME disk usage"); cancel(); } } diff --git a/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java b/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java index ae1f5ea1b1280096e784d57a2aafabe7159b162d..b0b9373586ccaaaa8429ab1a6616d9a8fb69209a 100644 --- a/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java +++ b/core/src/main/java/hudson/diagnosis/HudsonHomeDiskUsageMonitor.java @@ -37,7 +37,7 @@ import java.io.IOException; import java.util.List; /** - * Monitors the disk usage of HUDSON_HOME, and if it's almost filled up, warn the user. + * Monitors the disk usage of JENKINS_HOME, and if it's almost filled up, warn the user. * * @author Kohsuke Kawaguchi */ @@ -90,13 +90,13 @@ public final class HudsonHomeDiskUsageMonitor extends AdministrativeMonitor { } /** - * Extension point for suggesting solutions for full HUDSON_HOME. + * Extension point for suggesting solutions for full JENKINS_HOME. * *

Views

*
*
message.jelly
*
- * This view is rendered inside an LI tag as a possible solution to the full HUDSON_HOME problem. + * This view is rendered inside an LI tag as a possible solution to the full JENKINS_HOME problem. *
*
*/ diff --git a/core/src/main/java/hudson/init/InitStrategy.java b/core/src/main/java/hudson/init/InitStrategy.java index ca4aa48fbbd456003d972b65fc8ce027e6136bf7..84951731962deab0961772f9017150ceadf9a220 100644 --- a/core/src/main/java/hudson/init/InitStrategy.java +++ b/core/src/main/java/hudson/init/InitStrategy.java @@ -32,7 +32,7 @@ public class InitStrategy { * Returns the list of *.hpi and *.hpl to expand and load. * *

- * Normally we look at {@code $HUDSON_HOME/plugins/*.hpi} and *.hpl. + * Normally we look at {@code $JENKINS_HOME/plugins/*.hpi} and *.hpl. * * @return * never null but can be empty. The list can contain different versions of the same plugin, diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index 38cc7d6908f93d9403a46272103662ff9ed9dd2b..780e21e862839a91e81c3d49e5838854ab06c2ab 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -2363,7 +2363,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl pluginManager.stop(); if(getRootDir().exists()) - // if we are aborting because we failed to create HUDSON_HOME, + // if we are aborting because we failed to create JENKINS_HOME, // don't try to save. Issue #536 getQueue().save(); @@ -2917,7 +2917,7 @@ public final class Hudson extends Node implements ItemGroup, Stapl } /** - * Binds /userContent/... to $HUDSON_HOME/userContent. + * Binds /userContent/... to $JENKINS_HOME/userContent. */ public DirectoryBrowserSupport doUserContent() { return new DirectoryBrowserSupport(this,getRootPath().child("userContent"),"User content","folder.gif",true); diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index e962f310c2df0a3e66a229f0435dffcedd3168e7..7c50caa2f3d90eabf6987d6bfc0012a248ad3788 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -1771,8 +1771,8 @@ public abstract class Run ,RunT extends RunHUDSON_HOME directory, + * Makes sure that no other Hudson uses our JENKINS_HOME directory, * to forestall the problem of running multiple instances of Hudson that point to the same data directory. * *

diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java b/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java index 8c5b9c81423a5bcb6bec7562094c40e5184350f2..7beb020c5ecca92649619300a210c9a2ddc1f6fc 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonHomeLoader.java @@ -33,13 +33,13 @@ import java.net.MalformedURLException; import java.net.URL; /** - * Controls how a {@link HudsonTestCase} initializes HUDSON_HOME. + * Controls how a {@link HudsonTestCase} initializes JENKINS_HOME. * * @author Kohsuke Kawaguchi */ public interface HudsonHomeLoader { /** - * Returns a directory to be used as HUDSON_HOME + * Returns a directory to be used as JENKINS_HOME * * @throws Exception * to cause a test to fail. diff --git a/test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java b/test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java index 999b4a0d26a7175f864b779b9aa9c7c713306583..1140f72212fd96bb159890eec0021a13201fa09e 100644 --- a/test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java +++ b/test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java @@ -84,7 +84,7 @@ public class TestPluginManager extends PluginManager { } // and pick up test dependency *.hpi that are placed by maven-hpi-plugin TestDependencyMojo. - // and copy them into $HUDSON_HOME/plugins. + // and copy them into $JENKINS_HOME/plugins. URL index = getClass().getResource("/test-dependencies/index"); if (index!=null) {// if built with maven-hpi-plugin < 1.52 this file won't exist. BufferedReader r = new BufferedReader(new InputStreamReader(index.openStream(),"UTF-8")); diff --git a/test/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java b/test/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java index 00ab80617e36c6b98e8eadfcd55241c00a331200..5bc007e4577ea4fc3c610071f15836417723f4c6 100644 --- a/test/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java +++ b/test/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java @@ -36,7 +36,7 @@ import static java.lang.annotation.ElementType.METHOD; * Runs a test case with a data set local to test method or the test class. * *

- * This recipe allows your test case to start with the preset HUDSON_HOME data loaded + * This recipe allows your test case to start with the preset JENKINS_HOME data loaded * either from your test method or from the test class. * *

@@ -47,12 +47,12 @@ import static java.lang.annotation.ElementType.METHOD; *

    *
  1. * Under org/acme/FooTest/testBar directory (that is, you'll have - * org/acme/FooTest/testBar/config.xml), in the same layout as in the real HUDSON_HOME directory. + * org/acme/FooTest/testBar/config.xml), in the same layout as in the real JENKINS_HOME directory. *
  2. * In org/acme/FooTest/testBar.zip as a zip file. *
  3. * Under org/acme/FooTest directory (that is, you'll have - * org/acme/FooTest/config.xml), in the same layout as in the real HUDSON_HOME directory. + * org/acme/FooTest/config.xml), in the same layout as in the real JENKINS_HOME directory. *
  4. * In org/acme/FooTest.zip as a zip file. *
diff --git a/test/src/main/java/org/jvnet/hudson/test/recipes/PresetData.java b/test/src/main/java/org/jvnet/hudson/test/recipes/PresetData.java index 8d88964f353899ce3cd569b05d712a37c92b57e0..9b383c237b7e12a6af52b8098e2860c62545b6d0 100644 --- a/test/src/main/java/org/jvnet/hudson/test/recipes/PresetData.java +++ b/test/src/main/java/org/jvnet/hudson/test/recipes/PresetData.java @@ -33,7 +33,7 @@ import java.lang.annotation.Target; import java.util.Locale; /** - * Runs a test case with one of the preset HUDSON_HOME data set. + * Runs a test case with one of the preset JENKINS_HOME data set. * * @author Kohsuke Kawaguchi * @see LocalData