public class PluginManager extends Object
| Constructor and Description |
|---|
PluginManager(Config cfg) |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Plugin> |
bundledPlugins()
Finds the plugins and their versions bundled in the war file specified in the Config class.
|
void |
checkVersionCompatibility(hudson.util.VersionNumber jenkinsVersion,
List<Plugin> pluginsToBeDownloaded)
Checks that required Jenkins version of all plugins to be downloaded is less than the Jenkins version in the
user specified Jenkins war file
|
boolean |
downloadPlugin(Plugin plugin,
File location)
Downloads a plugin, skipping if already installed or bundled in the war.
|
void |
downloadPlugins(List<Plugin> plugins)
Downloads a list of plugins.
|
boolean |
downloadToFile(String urlString,
Plugin plugin,
File fileLocation)
Downloads a plugin from a url to a file.
|
boolean |
downloadToFile(String urlString,
Plugin plugin,
File fileLocation,
int maxRetries)
Downloads a plugin from a url to a file.
|
Map<String,Plugin> |
findEffectivePlugins(List<Plugin> pluginsToBeDownloaded)
Finds the final set of plugins that have been either been installed or will be downloaded.
|
Map<String,Plugin> |
findPluginsAndDependencies(List<Plugin> requestedPlugins)
Given a list of plugins, finds the recursive set of all dependent plugins.
|
List<Plugin> |
findPluginsToDownload(Map<String,Plugin> requestedPlugins)
Compares the list of all requested plugins to the currently installed plugins to determine the final list of
plugins that will be downloaded
|
String |
getAttributeFromManifest(File file,
String key)
Deprecated.
|
List<Plugin> |
getFailedPlugins()
Gets the list of failed plugins
|
String |
getJenkinsUCLatest()
Gets the update center url string
|
hudson.util.VersionNumber |
getJenkinsVersion()
Gets Jenkins version using one of the available methods.
|
hudson.util.VersionNumber |
getJenkinsVersionFromWar()
Gets the Jenkins version from the manifest in the Jenkins war specified in the Config class
|
org.json.JSONObject |
getJson(String urlString)
Deprecated.
|
org.json.JSONObject |
getJson(URL url,
String cacheKey)
Retrieves JSON from a URL and caches it
|
hudson.util.VersionNumber |
getLatestPluginVersion(String pluginName)
Retrieves the latest available version of a specified plugin.
|
List<Plugin> |
getLatestVersionsOfPlugins(List<Plugin> plugins)
Takes a list of plugins and returns the latest version
Returns existing version if no update
|
org.json.JSONArray |
getPluginDependencyJsonArray(Plugin plugin,
org.json.JSONObject ucJson)
Gets the JSONArray containing plugin a
|
String |
getPluginDownloadUrl(Plugin plugin)
Determines the plugin download url.
|
String |
getPluginVersion(File file)
Finds the plugin version by reading the manifest of a .hpi or .jpi file
|
Map<String,List<SecurityWarning>> |
getSecurityWarnings()
Gets the security warnings for plugins from the update center json and creates a list of all the security
warnings
|
void |
getUCJson(hudson.util.VersionNumber jenkinsVersion)
Gets update center json, which is later used to determine plugin dependencies and security warnings
|
Map<String,Plugin> |
installedPlugins()
Finds all the plugins and their versions currently in the plugin directory specified in the Config class
|
void |
listPlugins()
Lists installed plugins, bundled plugins, set of all recurively determined requested plugins, which plugins will
actually be downloaded based on the requested plugins and currently installed plugins, and the effective plugin
set, which includes all currently installed plugins and plugins that will be downloaded by the tool
|
void |
logPlugins(String description,
List<Plugin> plugins)
Given a list of plugins and a description, prints them out
|
void |
logVerbose(String message)
Outputs information to the console if verbose option was set to true
|
void |
outputPluginReplacementInfo(Plugin lowerVersion,
Plugin higherVersion)
Outputs information about a lower version of a plugin being replaced by a higher version
|
List<Plugin> |
resolveDependenciesFromJson(Plugin plugin,
org.json.JSONObject pluginJson)
Given a plugin and json that contains plugin information, determines the dependencies and returns the list of
dependencies.
|
List<Plugin> |
resolveDependenciesFromManifest(Plugin plugin)
Resolves direct dependencies from downloaded plugin manifest.
|
List<Plugin> |
resolveDirectDependencies(Plugin plugin)
Finds the dependencies for plugins by either resolving the information from the manifest or update center json.
|
Map<String,Plugin> |
resolveRecursiveDependencies(Plugin plugin)
Finds all recursive dependencies for a given plugin.
|
void |
setAllPluginsAndDependencies(Map<String,Plugin> allPluginsAndDependencies)
Sets all plugins and their recursive dependencies
|
void |
setAllSecurityWarnings(Map<String,List<SecurityWarning>> securityWarnings)
Sets the security warnings
|
void |
setBundledPluginVersions(Map<String,Plugin> bundledPlugins)
Sets the bundled plugins
|
void |
setCm(CacheManager cm) |
void |
setEffectivePlugins(Map<String,Plugin> effectivePlugins)
Sets the list of effective plugins
|
void |
setExperimentalPlugins(org.json.JSONObject experimentalPlugins)
Sets the json object containing latest experimental plugin information
|
void |
setExperimentalUcJson(org.json.JSONObject experimentalUcJson)
Sets the json object containing latest experimental plugin information
|
void |
setInstalledPluginVersions(Map<String,Plugin> installedPlugins)
Sets the installed plugins
|
void |
setJenkinsUCLatest(String updateCenterLatest)
Sets the update center url string
|
void |
setLatestUcJson(org.json.JSONObject latestUcJson)
Sets the latest update center json
|
void |
setLatestUcPlugins(org.json.JSONObject latestPlugins)
Sets the json object containing latest plugin information
|
void |
setPluginInfoJson(org.json.JSONObject pluginInfoJson)
Sets the plugin version json
|
void |
setPluginsToBeDownloaded(List<Plugin> pluginsToBeDownloaded)
Sets the list of plugins to be downloaded
|
void |
showAllSecurityWarnings()
Prints out all security warnings if isShowAllWarnings is set to true in the config file
|
void |
showSpecificSecurityWarnings(List<Plugin> plugins)
Prints out security warning information for a list of plugins if isShowWarnings is set to true in the config
file
|
void |
start()
Drives the process to download plugins.
|
void |
start(boolean downloadUc)
Drives the process to download plugins.
|
boolean |
warningExists(Plugin plugin)
Checks if a security warning exists for a plugin and its version.
|
public PluginManager(Config cfg)
public void start()
public void start(boolean downloadUc)
downloadUc - false to disable Update Center and other external resources download.
In such case the update center metadata should be provided by API.public List<Plugin> findPluginsToDownload(Map<String,Plugin> requestedPlugins)
requestedPlugins - list of all requested plugins, determined from the highest required versions of the
initial user requested plugins and their recursive dependenciespublic Map<String,Plugin> findEffectivePlugins(List<Plugin> pluginsToBeDownloaded)
pluginsToBeDownloaded - list of plugins and recursive dependencies requested by userpublic void listPlugins()
public void logPlugins(String description, List<Plugin> plugins)
description - string describing plugins to be printedplugins - list of plugins to be outputpublic Map<String,List<SecurityWarning>> getSecurityWarnings()
public void showAllSecurityWarnings()
public void showSpecificSecurityWarnings(List<Plugin> plugins)
plugins - list of plugins for which to see security warningspublic List<Plugin> getLatestVersionsOfPlugins(List<Plugin> plugins)
plugins - updated list of pluginspublic boolean warningExists(Plugin plugin)
plugin - to check for security warningpublic void checkVersionCompatibility(hudson.util.VersionNumber jenkinsVersion,
List<Plugin> pluginsToBeDownloaded)
pluginsToBeDownloaded - list of plugins to check version compatibility with the Jenkins versionpublic void downloadPlugins(List<Plugin> plugins)
plugins - list of plugins to downloadpublic Map<String,Plugin> findPluginsAndDependencies(List<Plugin> requestedPlugins)
requestedPlugins - list of plugins to find all dependencies forpublic void outputPluginReplacementInfo(Plugin lowerVersion, Plugin higherVersion)
lowerVersion - lower version of pluginhigherVersion - higher version of plugin@Deprecated public org.json.JSONObject getJson(String urlString)
getJson(URL, String)urlString - string representing the url from which to get the json objectpublic org.json.JSONObject getJson(URL url, String cacheKey)
url - the url to retrieve json fromcacheKey - a key to use for caching i.e. 'update-center'public void getUCJson(hudson.util.VersionNumber jenkinsVersion)
jenkinsVersion - the version of Jenkins to usepublic org.json.JSONArray getPluginDependencyJsonArray(Plugin plugin, org.json.JSONObject ucJson)
plugin - to get depedencies forucJson - update center json from which to parse dependenciespublic hudson.util.VersionNumber getLatestPluginVersion(String pluginName)
pluginName - the name of the pluginIllegalStateException - Update Center JSON has not been retrieved yetpublic List<Plugin> resolveDependenciesFromManifest(Plugin plugin)
plugin - plugin to resolve direct dependencies forpublic List<Plugin> resolveDependenciesFromJson(Plugin plugin, org.json.JSONObject pluginJson)
plugin - for which to find dependenciespluginJson - json that will be parsed to find requested plugin's dependenciespublic List<Plugin> resolveDirectDependencies(Plugin plugin)
plugin - for which to find and download dependenciespublic Map<String,Plugin> resolveRecursiveDependencies(Plugin plugin)
plugin - to resolve dependencies forpublic boolean downloadPlugin(Plugin plugin, @CheckForNull File location)
plugin - to downloadlocation - location to download plugin to. If location is set to null, will download to the plugin folder
otherwise will download to the temporary location specified.public String getPluginDownloadUrl(Plugin plugin)
plugin - to downloadpublic boolean downloadToFile(String urlString, Plugin plugin, @CheckForNull File fileLocation)
urlString - String url to download the plugin fromplugin - Plugin object representing plugin to be downloadedfileLocation - contains the temp file if the plugin is downloaded so that dependencies can be parsed from
the manifest, if the plugin will be downloaded to the plugin download location, this will
be nullpublic boolean downloadToFile(String urlString, Plugin plugin, @CheckForNull File fileLocation, int maxRetries)
urlString - String url to download the plugin fromplugin - Plugin object representing plugin to be downloadedfileLocation - contains the temp file if the plugin is downloaded so that dependencies can be parsed from
the manifest, if the plugin will be downloaded to the plugin download location, this will
be nullmaxRetries - Maximum number of times to retry the download before failing@CheckForNull public hudson.util.VersionNumber getJenkinsVersion()
null if it cannot be determined@CheckForNull public hudson.util.VersionNumber getJenkinsVersionFromWar()
null if the version cannot be determinedpublic String getPluginVersion(File file)
file - plugin .hpi or .jpi of which to get the version@Deprecated public String getAttributeFromManifest(File file, String key)
ManifestTools.getAttributeFromManifest(File, String)public Map<String,Plugin> installedPlugins()
public Map<String,Plugin> bundledPlugins()
public String getJenkinsUCLatest()
public void setJenkinsUCLatest(String updateCenterLatest)
updateCenterLatest - String in which to set the update center url stringpublic void setInstalledPluginVersions(Map<String,Plugin> installedPlugins)
installedPlugins - hashmap of plugin names and versions of plugins that already exist in the plugin
download directorypublic void setBundledPluginVersions(Map<String,Plugin> bundledPlugins)
bundledPlugins - hashmap of plugin names and version numbers representing the bundled pluginspublic void setAllPluginsAndDependencies(Map<String,Plugin> allPluginsAndDependencies)
allPluginsAndDependencies - map of plugin name - plugin pairs corresponding the requested plugins and their
recursive dependenciespublic void setEffectivePlugins(Map<String,Plugin> effectivePlugins)
effectivePlugins - map of plugin name - plugin pairs corresponding to the highest required versions of
the requested plugins, their dependencies, and the already installed pluginspublic void setPluginsToBeDownloaded(List<Plugin> pluginsToBeDownloaded)
pluginsToBeDownloaded - list of all plugins that will actually be downloaded after plugin dependencies have
been resolved and already installed plugins are taken into considerationpublic void logVerbose(String message)
message - informational string to outputpublic void setLatestUcJson(org.json.JSONObject latestUcJson)
latestUcJson - json to set latest update center topublic void setLatestUcPlugins(org.json.JSONObject latestPlugins)
latestPlugins - JSONObject containing info for latest pluginspublic void setExperimentalUcJson(org.json.JSONObject experimentalUcJson)
experimentalUcJson - JSONObject containing info for latest and experimental pluginspublic void setExperimentalPlugins(org.json.JSONObject experimentalPlugins)
experimentalPlugins - JSONObject containing info for latest experimental pluginspublic void setAllSecurityWarnings(Map<String,List<SecurityWarning>> securityWarnings)
securityWarnings - map of the plugin name to the list of security warnings for that pluginpublic void setPluginInfoJson(org.json.JSONObject pluginInfoJson)
pluginInfoJson - json to set plugin version info topublic void setCm(CacheManager cm)
Copyright © 2004–2020. All rights reserved.