提交 c11e2650 编写于 作者: S Stephen Connolly

Merge pull request #2012 from stephenc/jenkins-32765

[FIXED JENKINS-32765] Allow the directory that plugins are exploded into to be changed
......@@ -162,7 +162,8 @@ public class ClassicPluginStrategy implements PluginStrategy {
if (archive.isDirectory()) {// already expanded
expandDir = archive;
} else {
expandDir = new File(archive.getParentFile(), getBaseName(archive.getName()));
File f = pluginManager.getWorkDir();
expandDir = new File(f == null ? archive.getParentFile() : f, getBaseName(archive.getName()));
explode(archive, expandDir);
}
......
......@@ -149,6 +149,13 @@ 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}.
*/
@CheckForNull
private final File workDir;
/**
* @deprecated as of 1.355
* {@link PluginManager} can now live longer than {@link jenkins.model.Jenkins} instance, so
......@@ -199,6 +206,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 && context != null) {
workDir = context.getInitParameter(PluginManager.class.getName() + ".workDir");
}
this.workDir = workDir == null ? null : new File(workDir);
strategy = createPluginStrategy();
......@@ -218,6 +230,15 @@ 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.
*/
@CheckForNull
public File getWorkDir() {
return workDir;
}
/**
* Find all registered overrides (intended to allow overriding/adding views)
* @return List of extensions
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册