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 |
checkAndSetLatestUpdateCenter()
Determines if there is an update center for the version of Jenkins in the war file.
|
void |
checkVersionCompatibility(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.
|
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)
Given a jar file and a key to retrieve from the jar's MANIFEST.MF file, confirms that the file is a jar returns
the value matching the key
|
List<Plugin> |
getFailedPlugins()
Gets the list of failed plugins
|
String |
getJenkinsUCLatest()
Gets the update center url string
|
hudson.util.VersionNumber |
getJenkinsVersion()
Gets the Jenkins version
|
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)
Gets the json object at the given url
|
hudson.util.VersionNumber |
getLatestPluginVersion(String pluginName) |
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()
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 inforation 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 |
setEffectivePlugins(Map<String,Plugin> effectivePlugins)
Sets the list of effective plugins
|
void |
setInstalledPluginVersions(Map<String,Plugin> installedPlugins)
Sets the installed plugins
|
void |
setJenkinsUCLatest(String updateCenterLatest)
Sets the update center url string
|
void |
setJenkinsVersion(hudson.util.VersionNumber jenkinsVersion)
Sets Jenkins Version.
|
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 |
showAvailableUpdates(List<Plugin> plugins)
Prints out if any plugins of a given list have available updates in the latest update center
|
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.
|
boolean |
warningExists(Plugin plugin)
Checks if a security warning exists for a plugin and its version.
|
public static final String SEPARATOR
public PluginManager(Config cfg)
public void start()
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 void showAvailableUpdates(List<Plugin> plugins)
plugins - List of plugins to check versions against latest versions in update centerpublic boolean warningExists(Plugin plugin)
plugin - to check for security warningpublic void checkVersionCompatibility(List<Plugin> pluginsToBeDownloaded)
pluginsToBeDownloaded - list of plugins to check version compatibility with the Jenkins versionpublic void checkAndSetLatestUpdateCenter()
public 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 pluginpublic org.json.JSONObject getJson(String urlString)
urlString - string representing the url from which to get the json objectpublic void getUCJson()
public 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 pluginpublic 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, 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, 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 String getAttributeFromManifest(File file, String key)
file - jar file to get manifest fromkey - key matching value to retrievepublic hudson.util.VersionNumber getJenkinsVersionFromWar()
public String getPluginVersion(File file)
file - plugin .hpi or .jpi of which to get the versionpublic Map<String,Plugin> installedPlugins()
public Map<String,Plugin> bundledPlugins()
public void setJenkinsVersion(hudson.util.VersionNumber jenkinsVersion)
jenkinsVersion - version of Jenkins, used for checking/setting version specific update centerpublic hudson.util.VersionNumber getJenkinsVersion()
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 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 toCopyright © 2004–2020. All rights reserved.