Skip to content

Commit

Permalink
Merge pull request #464 from oleg-nenashev/plugin-manager-customizable
Browse files Browse the repository at this point in the history
Make plugin manager customizable via system properties
  • Loading branch information
oleg-nenashev authored Jan 26, 2021
2 parents fb80f71 + dddeb6f commit 5879302
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,13 @@ public PluginManager getPluginManager() {
* Sets the {@link PluginManager} to be used when creating a new {@link Jenkins} instance.
*
* @param pluginManager
* null to let Jenkins create a new instance of default plugin manager, like it normally does when running as a webapp outside the test.
* {@code null} to let Jenkins create a new instance of default plugin manager, like it normally does when running as a webapp outside the test.
*/
public void setPluginManager(PluginManager pluginManager) {
this.pluginManager = pluginManager;
if (jenkins!=null)
if (jenkins!=null) {
throw new IllegalStateException("Too late to override the plugin manager");
}
}

public JenkinsEmbedder with(PluginManager pluginManager) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package io.jenkins.jenkinsfile.runner;

import hudson.ClassicPluginStrategy;
import hudson.PluginManager;
import hudson.util.PluginServletFilter;
import io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherCommand;
import io.jenkins.jenkinsfile.runner.bootstrap.commands.JenkinsLauncherOptions;
import io.jenkins.jenkinsfile.runner.util.JenkinsHomeLoader;
import jenkins.model.Jenkins;
import jenkins.util.SystemProperties;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.security.AbstractLoginService;
import org.eclipse.jetty.security.LoginService;
import org.eclipse.jetty.server.Server;
Expand Down Expand Up @@ -84,7 +87,15 @@ protected ServletContext createWebServer() throws Exception {

localPort = -1;

setPluginManager(new PluginManagerImpl(context.getServletContext(), launcherOptions.pluginsDir));
String pluginManagerClass = SystemProperties.getString(PluginManager.CUSTOM_PLUGIN_MANAGER);
if (pluginManagerClass == null) {
// Standard plugin manager for JFR
setPluginManager(new PluginManagerImpl(context.getServletContext(), launcherOptions.pluginsDir));
} else {
LOGGER.log(Level.INFO, "Will use a custom plugin manager {0}. " +
"Note that the --pluginsDir option is not used in this case. ", pluginManagerClass);
setPluginManager(null);
}

return context.getServletContext();
}
Expand Down

0 comments on commit 5879302

Please sign in to comment.