@ExportedBean public abstract class PluginManager extends AbstractModelObject implements OnMaster, org.kohsuke.stapler.StaplerOverridable
PluginWrapper
s.
Setting default Plugin Managers. The default plugin manager in Jenkins
can be replaced by defining a
System Property (hudson.PluginManager.className
). See createDefault(Jenkins)
.
This className should be available on early startup, so it cannot come only from a library
(e.g. Jenkins module or Extra library dependency in the WAR file project).
Plugins cannot be used for such purpose.
In order to be correctly instantiated, the class definition must have at least one constructor with the same
signature as the following ones:
LocalPluginManager.LocalPluginManager(Jenkins)
LocalPluginManager.LocalPluginManager(ServletContext, File)
LocalPluginManager.LocalPluginManager(File)
File
argument refers to the Jenkins home directory.Modifier and Type | Class and Description |
---|---|
static class |
PluginManager.FailedPlugin
Remembers why a plugin failed to deploy.
|
static class |
PluginManager.PluginCycleDependenciesMonitor
AdministrativeMonitor that checks if there are any plugins with cycle dependencies. |
static class |
PluginManager.PluginUpdateMonitor
AdministrativeMonitor that informs the administrator about a required plugin update. |
class |
PluginManager.UberClassLoader
ClassLoader that can see all plugins. |
Modifier and Type | Field and Description |
---|---|
protected List<PluginWrapper> |
activePlugins
All active plugins, topologically sorted so that when X depends on Y, Y appears in the list before X does.
|
static Permission |
CONFIGURE_UPDATECENTER |
javax.servlet.ServletContext |
context
Deprecated.
as of 1.355
PluginManager can now live longer than Jenkins instance, so
use Hudson.getInstance().servletContext instead. |
static String |
CUSTOM_PLUGIN_MANAGER
Custom plugin manager system property or context param.
|
protected List<PluginManager.FailedPlugin> |
failedPlugins |
static boolean |
FAST_LOOKUP |
protected List<PluginWrapper> |
plugins
All discovered plugins.
|
boolean |
pluginUploaded
Once plugin is uploaded, this flag becomes true.
|
File |
rootDir
Plug-in root directory.
|
ClassLoader |
uberClassLoader
ClassLoader that can load all the publicly visible classes from plugins
(and including the classloader that loads Hudson itself.) |
static Permission |
UPLOAD_PLUGINS |
Constructor and Description |
---|
PluginManager(javax.servlet.ServletContext context,
File rootDir) |
Modifier and Type | Method and Description |
---|---|
protected static void |
addDependencies(URL hpiResUrl,
String fromPath,
Set<URL> dependencySet) |
protected void |
copyBundledPlugin(URL src,
String fileName)
Copies the bundled plugin from the given URL to the destination of the given file name (like 'abc.jpi'),
with a reasonable up-to-date check.
|
static PluginManager |
createDefault(Jenkins jenkins)
Creates the
PluginManager to use if no one is provided to a Jenkins object. |
protected PluginStrategy |
createPluginStrategy()
Creates a hudson.PluginStrategy, looking at the corresponding system property.
|
<T> Collection<Class<? extends T>> |
discover(Class<T> spi)
Discover all the service provider implementations of the given class,
via META-INF/services.
|
org.kohsuke.stapler.HttpResponse |
doCheckUpdatesServer() |
void |
doInstall(org.kohsuke.stapler.StaplerRequest req,
org.kohsuke.stapler.StaplerResponse rsp)
Performs the installation of the plugins.
|
org.kohsuke.stapler.HttpResponse |
doInstallNecessaryPlugins(org.kohsuke.stapler.StaplerRequest req)
Runs
prevalidateConfig(java.io.InputStream) on posted XML and redirects to the UpdateCenter . |
org.kohsuke.stapler.HttpResponse |
doInstallPlugins(org.kohsuke.stapler.StaplerRequest req)
Installs a list of plugins from a JSON POST.
|
void |
doInstallPluginsDone()
Called to progress status beyond installing plugins, e.g.
|
org.kohsuke.stapler.HttpResponse |
doPlugins()
Get the list of all plugins - available and installed.
|
net.sf.json.JSONArray |
doPrevalidateConfig(org.kohsuke.stapler.StaplerRequest req)
Like
doInstallNecessaryPlugins(StaplerRequest) but only checks if everything is installed
or if some plugins need updates or installation. |
org.kohsuke.stapler.HttpResponse |
doProxyConfigure(org.kohsuke.stapler.StaplerRequest req) |
org.kohsuke.stapler.HttpResponse |
doSiteConfigure(String site)
Bare-minimum configuration mechanism to change the update center.
|
org.kohsuke.stapler.HttpResponse |
doUpdateSources(org.kohsuke.stapler.StaplerRequest req) |
org.kohsuke.stapler.HttpResponse |
doUploadPlugin(org.kohsuke.stapler.StaplerRequest req)
Uploads a plugin.
|
void |
dynamicLoad(File arc)
TODO: revisit where/how to expose this.
|
void |
dynamicLoad(File arc,
boolean removeExisting)
Try the dynamicLoad, removeExisting to attempt to dynamic load disabled plugins
|
Api |
getApi() |
Manifest |
getBundledPluginManifest(String shortName)
Deprecated.
|
org.jenkinsci.bytecode.Transformer |
getCompatibilityTransformer() |
String |
getDisplayName() |
List<PluginManager.FailedPlugin> |
getFailedPlugins() |
Collection<PluginManagerStaplerOverride> |
getOverrides()
Find all registered overrides (intended to allow overriding/adding views)
|
PluginWrapper |
getPlugin(Class<? extends Plugin> pluginClazz)
Get the plugin instance that implements a specific class, use to find your plugin singleton.
|
PluginWrapper |
getPlugin(String shortName)
Get the plugin instance with the given short name.
|
List<PluginWrapper> |
getPlugins()
All discovered plugins.
|
List<PluginWrapper> |
getPlugins(Class<? extends Plugin> pluginSuperclass)
Get the plugin instances that extend a specific class, use to find similar plugins.
|
PluginStrategy |
getPluginStrategy() |
Descriptor<ProxyConfiguration> |
getProxyDescriptor() |
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
File |
getWorkDir()
If non-null, the base directory for all exploded .hpi/.jpi plugins.
|
protected String |
identifyPluginShortName(File t) |
org.jvnet.hudson.reactor.TaskBuilder |
initTasks(InitStrategy initStrategy)
Called immediately after the construction.
|
List<Future<UpdateCenter.UpdateCenterJob>> |
install(Collection<String> plugins,
boolean dynamicLoad)
Performs the installation of the plugins.
|
boolean |
isPluginUploaded()
Returns true if any new plugin was added.
|
protected abstract Collection<String> |
loadBundledPlugins()
If the war file has any "/WEB-INF/plugins/[*.jpi | *.hpi]", extract them into the plugin directory.
|
protected void |
loadDetachedPlugins()
Load detached plugins and their dependencies.
|
protected Set<String> |
loadPluginsFromWar(String fromPath) |
protected Set<String> |
loadPluginsFromWar(String fromPath,
FilenameFilter filter) |
Map<String,VersionNumber> |
parseRequestedPlugins(InputStream configXml)
Parses configuration XML files and picks up references to XML files.
|
List<Future<UpdateCenter.UpdateCenterJob>> |
prevalidateConfig(InputStream configXml)
Prepares plugins for some expected XML configuration.
|
void |
resolveDependantPlugins() |
void |
stop()
Orderly terminates all the plugins.
|
PluginWrapper |
whichPlugin(Class c)
Return the
PluginWrapper that loaded the given class 'c'. |
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
public static final String CUSTOM_PLUGIN_MANAGER
protected final List<PluginWrapper> plugins
protected final List<PluginWrapper> activePlugins
protected final List<PluginManager.FailedPlugin> failedPlugins
public final File rootDir
@Deprecated public final javax.servlet.ServletContext context
PluginManager
can now live longer than Jenkins
instance, so
use Hudson.getInstance().servletContext
instead.public final ClassLoader uberClassLoader
ClassLoader
that can load all the publicly visible classes from plugins
(and including the classloader that loads Hudson itself.)public volatile boolean pluginUploaded
public static boolean FAST_LOOKUP
public static final Permission UPLOAD_PLUGINS
public static final Permission CONFIGURE_UPDATECENTER
public PluginManager(javax.servlet.ServletContext context, File rootDir)
@NonNull public static PluginManager createDefault(@NonNull Jenkins jenkins)
PluginManager
to use if no one is provided to a Jenkins
object.
This method will be called after creation of Jenkins
object, but before it is fully initialized.jenkins
- Jenkins Instance.LocalPluginManager
is returned.public org.jenkinsci.bytecode.Transformer getCompatibilityTransformer()
public Api getApi()
@CheckForNull public File getWorkDir()
null
to leave this up to the strategy.public Collection<PluginManagerStaplerOverride> getOverrides()
getOverrides
in interface org.kohsuke.stapler.StaplerOverridable
public org.jvnet.hudson.reactor.TaskBuilder initTasks(InitStrategy initStrategy)
Jenkins.pluginManager
.@Nonnull protected Set<String> loadPluginsFromWar(@Nonnull String fromPath, @CheckForNull FilenameFilter filter)
protected static void addDependencies(URL hpiResUrl, String fromPath, Set<URL> dependencySet) throws URISyntaxException, MalformedURLException
protected void loadDetachedPlugins()
Only loads plugins that:
@Deprecated @CheckForNull public Manifest getBundledPluginManifest(String shortName)
public void dynamicLoad(File arc) throws IOException, InterruptedException, RestartRequiredException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void dynamicLoad(File arc, boolean removeExisting) throws IOException, InterruptedException, RestartRequiredException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void resolveDependantPlugins()
protected abstract Collection<String> loadBundledPlugins() throws Exception
Exception
- Any exception will be reported and halt the startup.protected void copyBundledPlugin(URL src, String fileName) throws IOException
loadBundledPlugins()
.IOException
protected PluginStrategy createPluginStrategy()
public PluginStrategy getPluginStrategy()
public boolean isPluginUploaded()
@Exported public List<PluginWrapper> getPlugins()
public List<PluginManager.FailedPlugin> getFailedPlugins()
@CheckForNull public PluginWrapper getPlugin(String shortName)
shortName
- the short name of the pluginnull
if a plugin with the given short name does not exist.
The fact the plugin is loaded does not mean it is enabled and fully initialized for the current Jenkins session.
Use PluginWrapper.isActive()
to check it.@CheckForNull public PluginWrapper getPlugin(Class<? extends Plugin> pluginClazz)
pluginClazz
- The class that your plugin implements.null
if for some reason the plugin is not loaded.
The fact the plugin is loaded does not mean it is enabled and fully initialized for the current Jenkins session.
Use Plugin.getWrapper()
and then PluginWrapper.isActive()
to check it.public List<PluginWrapper> getPlugins(Class<? extends Plugin> pluginSuperclass)
pluginSuperclass
- The class that your plugin is derived from.public String getDisplayName()
getDisplayName
in interface ModelObject
public String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
public <T> Collection<Class<? extends T>> discover(Class<T> spi)
public PluginWrapper whichPlugin(Class c)
PluginWrapper
that loaded the given class 'c'.public void stop()
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public org.kohsuke.stapler.HttpResponse doPlugins()
public org.kohsuke.stapler.HttpResponse doUpdateSources(org.kohsuke.stapler.StaplerRequest req) throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public void doInstallPluginsDone()
public void doInstall(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public org.kohsuke.stapler.HttpResponse doInstallPlugins(org.kohsuke.stapler.StaplerRequest req) throws IOException
req
- The request object.UpdateCenter.doInstallStatus(org.kohsuke.stapler.StaplerRequest)
.IOException
- Error reading JSON payload fro request.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<Future<UpdateCenter.UpdateCenterJob>> install(@Nonnull Collection<String> plugins, boolean dynamicLoad)
plugins
- The collection of plugins to install.dynamicLoad
- If true, the plugin will be dynamically loaded into this Jenkins. If false,
the plugin will only take effect after the reboot.
See UpdateCenter.isRestartRequiredForCompletion()
public org.kohsuke.stapler.HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException
IOException
public org.kohsuke.stapler.HttpResponse doProxyConfigure(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpResponse doUploadPlugin(org.kohsuke.stapler.StaplerRequest req) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doCheckUpdatesServer() throws IOException
IOException
public Descriptor<ProxyConfiguration> getProxyDescriptor()
public List<Future<UpdateCenter.UpdateCenterJob>> prevalidateConfig(InputStream configXml) throws IOException
config.xml
)
needs some plugins to be installed (or updated), those jobs
will be triggered.
Plugins are dynamically loaded whenever possible.
Requires Jenkins.ADMINISTER
.configXml
- configuration that might be uploadedIOException
- if loading or parsing the configuration failedItemGroupMixIn.createProjectFromXML(java.lang.String, java.io.InputStream)
,
AbstractItem.updateByXml(javax.xml.transform.Source)
,
XStream2
,
UpdateSite.Plugin.deploy(boolean)
,
PluginWrapper.supportsDynamicLoad()
,
UpdateCenter.DownloadJob.SuccessButRequiresRestart
public net.sf.json.JSONArray doPrevalidateConfig(org.kohsuke.stapler.StaplerRequest req) throws IOException
doInstallNecessaryPlugins(StaplerRequest)
but only checks if everything is installed
or if some plugins need updates or installation.
This method runs without side-effect. I'm still requiring the ADMINISTER permission since
XML file can contain various external references and we don't configure parsers properly against
that.IOException
public org.kohsuke.stapler.HttpResponse doInstallNecessaryPlugins(org.kohsuke.stapler.StaplerRequest req) throws IOException
prevalidateConfig(java.io.InputStream)
on posted XML and redirects to the UpdateCenter
.IOException
public Map<String,VersionNumber> parseRequestedPlugins(InputStream configXml) throws IOException
IOException
Copyright © 2004–2017. All rights reserved.