@ExportedBean public abstract class PluginManager extends AbstractModelObject implements OnMaster, org.kohsuke.stapler.StaplerOverridable, org.kohsuke.stapler.StaplerProxy
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:
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.MetadataCache |
static class |
PluginManager.PluginCycleDependenciesMonitor
AdministrativeMonitor that checks if there are any plugins with cycle dependencies. |
static class |
PluginManager.PluginDeprecationMonitor
AdministrativeMonitor that checks if there are any plugins that are deprecated. |
static class |
PluginManager.PluginUpdateMonitor
AdministrativeMonitor that informs the administrator about a required plugin update. |
static 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
Deprecated.
in Jenkins 2.222 use
Jenkins.ADMINISTER instead |
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.
|
static boolean |
SKIP_PERMISSION_CHECK
Escape hatch for StaplerProxy-based access control
|
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
Deprecated.
in Jenkins 2.222 use
Jenkins.ADMINISTER instead |
Modifier | Constructor and Description |
---|---|
protected |
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 plugin from the given URL to the given destination.
|
PluginManager.MetadataCache |
createCache() |
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.
|
List<PluginWrapper.PluginDisableResult> |
disablePlugins(PluginWrapper.PluginDisableStrategy strategy,
List<String> plugins)
Disable a list of plugins using a strategy for their dependents plugins.
|
<T> Collection<Class<? extends T>> |
discover(Class<T> spi)
Deprecated.
Use
ServiceLoader instead, or (more commonly) ExtensionList . |
FormValidation |
doCheckPluginUrl(org.kohsuke.stapler.StaplerRequest request,
String value) |
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.
|
org.kohsuke.stapler.HttpResponse |
doPluginsSearch(String query,
Integer limit) |
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,
List<PluginWrapper> batch)
Try the dynamicLoad, removeExisting to attempt to dynamic load disabled plugins
|
Api |
getApi() |
Manifest |
getBundledPluginManifest(String shortName)
Deprecated.
removed without replacement
|
String |
getDisplayName() |
List<PluginManager.FailedPlugin> |
getFailedPlugins() |
String |
getLastErrorCheckUpdateCenters()
Returns the last error raised during the update sites checking.
|
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 . |
Object |
getTarget() |
File |
getWorkDir()
If non-null, the base directory for all exploded .hpi/.jpi plugins.
|
boolean |
hasAdoptThisPluginLabel(PluginWrapper plugin) |
boolean |
hasAdoptThisPluginLabel(UpdateSite.Plugin plugin) |
boolean |
hasLatestVersionNewerThanOffered(UpdateSite.Plugin plugin) |
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 |
isMetaLabel(String label) |
static boolean |
isNonMetaLabel(String label) |
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 |
resolveDependentPlugins() |
void |
start(List<PluginWrapper> plugins) |
void |
stop()
Orderly terminates all the plugins.
|
String |
unscientific(double d) |
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
@Deprecated public static final Permission UPLOAD_PLUGINS
Jenkins.ADMINISTER
instead@Deprecated public static final Permission CONFIGURE_UPDATECENTER
Jenkins.ADMINISTER
instead@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean SKIP_PERMISSION_CHECK
protected 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 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, @CheckForNull List<PluginWrapper> batch) throws IOException, InterruptedException, RestartRequiredException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void start(List<PluginWrapper> plugins) throws Exception
Exception
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void resolveDependentPlugins()
protected abstract Collection<String> loadBundledPlugins() throws Exception
loadDetachedPlugins()
) but OEM WARs may have some.Exception
- Any exception will be reported and halt the startup.protected void copyBundledPlugin(URL src, String fileName) throws IOException
loadDetachedPlugins()
.
Includes a reasonable up-to-date check.
A convenience method to be used by loadBundledPlugins()
.fileName
- like abc.jpi
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
@Deprecated public <T> Collection<Class<? extends T>> discover(Class<T> spi)
ServiceLoader
instead, or (more commonly) ExtensionList
.META-INF/services
.public PluginWrapper whichPlugin(Class c)
PluginWrapper
that loaded the given class 'c'.public void stop()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean isNonMetaLabel(String label)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doPluginsSearch(@QueryParameter String query, @QueryParameter Integer limit)
@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
@POST 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 FormValidation doCheckPluginUrl(org.kohsuke.stapler.StaplerRequest request, @QueryParameter String value) throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public org.kohsuke.stapler.HttpResponse doCheckUpdatesServer() throws IOException
IOException
public String getLastErrorCheckUpdateCenters()
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
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public PluginManager.MetadataCache createCache()
@NonNull public List<PluginWrapper.PluginDisableResult> disablePlugins(@NonNull PluginWrapper.PluginDisableStrategy strategy, @NonNull List<String> plugins) throws IOException
strategy
- the strategy regarding how the dependent plugins are processedplugins
- the list of pluginsIOException
- see PluginWrapper.disable()
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public String unscientific(double d)
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getTarget()
getTarget
in interface org.kohsuke.stapler.StaplerProxy
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public boolean isMetaLabel(String label)
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public boolean hasAdoptThisPluginLabel(UpdateSite.Plugin plugin)
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public boolean hasLatestVersionNewerThanOffered(UpdateSite.Plugin plugin)
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public boolean hasAdoptThisPluginLabel(PluginWrapper plugin)
Copyright © 2004–2022. All rights reserved.