Skip to content

Commit

Permalink
Merge pull request #2012 from stephenc/jenkins-32765
Browse files Browse the repository at this point in the history
[FIXED JENKINS-32765] Allow the directory that plugins are exploded into to be changed
  • Loading branch information
stephenc committed Feb 9, 2016
2 parents 51f215c + 566def3 commit c11e265
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/hudson/ClassicPluginStrategy.java
Expand Up @@ -162,7 +162,8 @@ private static Manifest loadLinkedManifest(File archive) throws IOException {
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);
}

Expand Down
21 changes: 21 additions & 0 deletions core/src/main/java/hudson/PluginManager.java
Expand Up @@ -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
Expand Down Expand Up @@ -199,6 +206,11 @@ public PluginManager(ServletContext context, File rootDir) {
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();

Expand All @@ -218,6 +230,15 @@ public Api getApi() {
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
Expand Down

0 comments on commit c11e265

Please sign in to comment.