diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 775a651d01..d644d95409 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -88,12 +88,6 @@ public class ClassicPluginStrategy implements PluginStrategy { } }; - /** - * If set this should be the absolute file path to the the base directory for all exploded .hpi/.jpi plugins. - * If {@literal null} then plugins will be exploded into {@literal JENKINS_HOME/plugins}. - */ - private static final String WORK_DIR = System.getProperty(ClassicPluginStrategy.class.getName() + ".WORK_DIR"); - private PluginManager pluginManager; /** @@ -168,10 +162,8 @@ public class ClassicPluginStrategy implements PluginStrategy { if (archive.isDirectory()) {// already expanded expandDir = archive; } else { - expandDir = WORK_DIR == null - ? new File(archive.getParentFile(), getBaseName(archive.getName())) - : new File(WORK_DIR, getBaseName(archive.getName())); - ; + File f = pluginManager.getWorkDir(); + expandDir = new File(f == null ? archive.getParentFile() : f, getBaseName(archive.getName())); explode(archive, expandDir); } diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index d7eb14f7b6..1a11f4bf33 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -149,6 +149,12 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas */ public final File rootDir; + /** + * If non-null, the base directory for all exploded .hpi/.jpi plugins. Controlled by the system property / servlet + * context parameter {@literal hudson.PluginManager.workDir}. + */ + private final File workDir; + /** * @deprecated as of 1.355 * {@link PluginManager} can now live longer than {@link jenkins.model.Jenkins} instance, so @@ -199,6 +205,11 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas this.rootDir = rootDir; if(!rootDir.exists()) rootDir.mkdirs(); + String workDir = System.getProperty(PluginManager.class.getName()+".workDir"); + if (workDir == null) { + workDir = context.getInitParameter(PluginManager.class.getName() + ".workDir"); + } + this.workDir = workDir == null ? null : new File(workDir); strategy = createPluginStrategy(); @@ -218,6 +229,14 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas return new Api(this); } + /** + * If non-null, the base directory for all exploded .hpi/.jpi plugins. + * @return the base directory for all exploded .hpi/.jpi plugins or {@code null} to leave this up to the strategy. + */ + public File getWorkDir() { + return workDir; + } + /** * Find all registered overrides (intended to allow overriding/adding views) * @return List of extensions