@ExportedBean public class UpdateCenter extends AbstractModelObject implements Saveable, OnMaster, org.kohsuke.stapler.StaplerProxy
The main job of this class is to keep track of the latest update center metadata file, and perform installations.
Much of the UI about choosing plugins to install is done in PluginManager
.
The update center can be configured to contact alternate servers for updates
and plugins, and to use alternate strategies for downloading, installing
and updating components. See the Javadocs for UpdateCenter.UpdateCenterConfiguration
for more information.
Extending Update Centers. The update center in Jenkins
can be replaced by defining a
System Property (hudson.model.UpdateCenter.className
). See createUpdateCenter(hudson.model.UpdateCenter.UpdateCenterConfiguration)
.
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 two constructors:
UpdateCenter()
and UpdateCenter(hudson.model.UpdateCenter.UpdateCenterConfiguration)
.
If the class does not comply with the requirements, a fallback to the default UpdateCenter will be performed.
Modifier and Type | Class and Description |
---|---|
class |
UpdateCenter.CompleteBatchJob |
class |
UpdateCenter.ConnectionCheckJob
Tests the internet connectivity.
|
static class |
UpdateCenter.CoreUpdateMonitor
AdministrativeMonitor that checks if there's Jenkins update. |
class |
UpdateCenter.DownloadJob
Base class for a job that downloads a file from the Jenkins project.
|
class |
UpdateCenter.EnableJob
Enables a required plugin, provides feedback in the update center
|
class |
UpdateCenter.HudsonDowngradeJob |
class |
UpdateCenter.HudsonUpgradeJob
Represents the state of the upgrade activity of Jenkins core.
|
class |
UpdateCenter.InstallationJob
Represents the state of the installation activity of one plugin.
|
class |
UpdateCenter.NoOpJob
A no-op, e.g.
|
class |
UpdateCenter.PluginDowngradeJob
Represents the state of the downgrading activity of plugin.
|
static class |
UpdateCenter.PluginEntry
Deprecated.
|
class |
UpdateCenter.RestartJenkinsJob
Restarts jenkins.
|
static class |
UpdateCenter.UpdateCenterConfiguration
Strategy object for controlling the update center's behaviors.
|
class |
UpdateCenter.UpdateCenterJob
Things that
installerService executes. |
Modifier and Type | Field and Description |
---|---|
static String |
ID_DEFAULT
ID of the default update site.
|
static String |
ID_UPLOAD |
static boolean |
neverUpdate
Deprecated.
as of 1.333
Use
UpdateSite.neverUpdate |
static String |
PREDEFINED_UPDATE_SITE_ID |
static boolean |
SKIP_PERMISSION_CHECK
Escape hatch for StaplerProxy-based access control
|
protected ExecutorService |
updateService
An
ExecutorService for updating UpdateSites. |
static XStream2 |
XSTREAM |
Constructor and Description |
---|
UpdateCenter() |
Modifier and Type | Method and Description |
---|---|
Future<UpdateCenter.UpdateCenterJob> |
addJob(UpdateCenter.UpdateCenterJob job) |
void |
configure(UpdateCenter.UpdateCenterConfiguration config)
Configures update center to get plugins/updates from alternate servers,
and optionally using alternate strategies for downloading, installing
and upgrading.
|
protected UpdateSite |
createDefaultUpdateSite() |
static UpdateCenter |
createUpdateCenter(UpdateCenter.UpdateCenterConfiguration config)
Creates an update center.
|
void |
doCancelRestart(org.kohsuke.stapler.StaplerResponse response)
Cancel all scheduled jenkins restarts
|
org.kohsuke.stapler.HttpResponse |
doConnectionStatus(org.kohsuke.stapler.StaplerRequest request)
Get the current connection status.
|
void |
doDowngrade(org.kohsuke.stapler.StaplerResponse rsp)
Performs hudson downgrade.
|
org.kohsuke.stapler.HttpResponse |
doIncompleteInstallStatus()
Called to determine if there was an incomplete installation, what the statuses of the plugins are
|
org.kohsuke.stapler.HttpResponse |
doInstallStatus(org.kohsuke.stapler.StaplerRequest request)
Get the current installation status of a plugin set.
|
org.kohsuke.stapler.HttpResponse |
doInvalidateData()
Invalidates the update center JSON data for all the sites and force re-retrieval.
|
void |
doRestart(org.kohsuke.stapler.StaplerResponse rsp)
Performs hudson downgrade.
|
void |
doSafeRestart(org.kohsuke.stapler.StaplerRequest request,
org.kohsuke.stapler.StaplerResponse response)
Schedules a Jenkins restart.
|
void |
doUpgrade(org.kohsuke.stapler.StaplerResponse rsp)
Schedules a Jenkins upgrade.
|
Api |
getApi() |
List<UpdateSite.Plugin> |
getAvailables() |
String |
getBackupVersion()
Returns String with version of backup .war file,
if the file does not exists returns null
|
UpdateSite |
getById(String id)
Gets
UpdateSite by its ID. |
UpdateCenter.PluginEntry[] |
getCategorizedAvailables()
Deprecated.
use
getAvailables() |
static String |
getCategoryDisplayName(String category) |
UpdateSite |
getCoreSource()
Gets the
UpdateSite from which we receive updates for jenkins.war . |
String |
getDefaultBaseUrl()
Deprecated.
TODO: revisit tool update mechanism, as that should be de-centralized, too. In the mean time,
please try not to use this method, and instead ping us to get this part completed.
|
String |
getDisplayName() |
UpdateCenter.HudsonUpgradeJob |
getHudsonJob()
Returns latest Jenkins upgrade job.
|
UpdateCenter.UpdateCenterJob |
getJob(int id)
Gets a job by its ID.
|
UpdateCenter.InstallationJob |
getJob(UpdateSite.Plugin plugin)
Returns latest install/upgrade job for the given plugin.
|
List<UpdateCenter.UpdateCenterJob> |
getJobs()
Returns the list of
UpdateCenter.UpdateCenterJob representing scheduled installation attempts. |
String |
getLastUpdatedString()
Gets the string representing how long ago the data was obtained.
|
UpdateSite.Plugin |
getPlugin(String artifactId)
Gets the plugin with the given name from the first
UpdateSite to contain it. |
UpdateSite.Plugin |
getPlugin(String artifactId,
VersionNumber minVersion)
Gets the plugin with the given name from the first
UpdateSite to contain it. |
List<UpdateSite.Plugin> |
getPluginFromAllSites(String artifactId,
VersionNumber minVersion)
Gets plugin info from all available sites
|
List<UpdateSite.Plugin> |
getPluginsWithUnavailableUpdates() |
String |
getSearchUrl()
Returns the URL of this item relative to the parent
SearchItem . |
UpdateSite |
getSite(String id)
Alias for
getById(java.lang.String) . |
List<UpdateSite> |
getSiteList()
The same as
getSites() but for REST API. |
PersistedList<UpdateSite> |
getSites()
Returns the list of
UpdateSite s to be used. |
Object |
getTarget() |
List<UpdateSite.Plugin> |
getUpdates() |
static void |
init(Jenkins h)
Initializes the update center.
|
boolean |
isDowngradable()
Returns true if backup of jenkins.war exists on the hard drive
|
boolean |
isRestartRequiredForCompletion()
If any of the executed
UpdateCenter.UpdateCenterJob s requires a restart
to take effect, this method returns true. |
boolean |
isRestartScheduled()
Checks if the restart operation is scheduled
(which means in near future Jenkins will restart by itself)
|
boolean |
isSiteDataReady()
Whether it is probably safe to call all
UpdateSite.getData() without blocking. |
void |
load()
Loads the data from the disk into this object.
|
void |
persistInstallStatus()
Called to persist the currently installing plugin states.
|
void |
save()
Saves the configuration info to the disk.
|
List<FormValidation> |
updateAllSites()
Ensure that all UpdateSites are up to date, without requiring a user to
browse to the instance.
|
static void |
updateAllSitesNow() |
static void |
updateDefaultSite() |
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
public static final String PREDEFINED_UPDATE_SITE_ID
public static final String ID_DEFAULT
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static final String ID_UPLOAD
protected final ExecutorService updateService
ExecutorService
for updating UpdateSites.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static boolean SKIP_PERMISSION_CHECK
@Deprecated public static boolean neverUpdate
UpdateSite.neverUpdate
public static final XStream2 XSTREAM
@NonNull public static UpdateCenter createUpdateCenter(@CheckForNull UpdateCenter.UpdateCenterConfiguration config)
config
- Requested configuration. May be null
if defaults should be usedUpdateCenter
by default, but may be overriddenpublic Api getApi()
public void configure(UpdateCenter.UpdateCenterConfiguration config)
config
- Configuration dataUpdateCenter.UpdateCenterConfiguration
@Exported @StaplerDispatchable public List<UpdateCenter.UpdateCenterJob> getJobs()
UpdateCenter.UpdateCenterJob
representing scheduled installation attempts.public UpdateCenter.UpdateCenterJob getJob(int id)
UpdateCenter.UpdateCenterJob
bound to URL.public UpdateCenter.InstallationJob getJob(UpdateSite.Plugin plugin)
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public org.kohsuke.stapler.HttpResponse doConnectionStatus(org.kohsuke.stapler.StaplerRequest request)
Supports a "siteId" request parameter, defaulting to ID_DEFAULT
for the default
update site.
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public org.kohsuke.stapler.HttpResponse doIncompleteInstallStatus()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public void persistInstallStatus()
@Restricted(value=org.kohsuke.accmod.restrictions.DoNotUse.class) public org.kohsuke.stapler.HttpResponse doInstallStatus(org.kohsuke.stapler.StaplerRequest request)
Supports a "correlationId" request parameter if you only want to get the
install status of a set of plugins requested for install through
PluginManager.doInstallPlugins(org.kohsuke.stapler.StaplerRequest)
.
public UpdateCenter.HudsonUpgradeJob getHudsonJob()
@StaplerDispatchable public PersistedList<UpdateSite> getSites()
UpdateSite
s to be used.
This is a live list, whose change will be persisted automatically.@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public boolean isSiteDataReady()
UpdateSite.getData()
without blocking.@Exported(name="sites") public List<UpdateSite> getSiteList()
getSites()
but for REST API.@CheckForNull public UpdateSite getSite(String id)
getById(java.lang.String)
.id
- ID of the update site to be retrievedUpdateSite
. null
if it cannot be foundpublic String getLastUpdatedString()
UpdateSite
s.@CheckForNull public UpdateSite getById(String id)
UpdateSite
by its ID.
Used to bind them to URL.id
- ID of the update site to be retrievedUpdateSite
. null
if it cannot be found@CheckForNull public UpdateSite getCoreSource()
UpdateSite
from which we receive updates for jenkins.war
.null
if no such update center is provided.@Deprecated public String getDefaultBaseUrl()
@CheckForNull public UpdateSite.Plugin getPlugin(String artifactId)
UpdateSite
to contain it.UpdateSite.Plugin
. null
if it cannot be found@CheckForNull public UpdateSite.Plugin getPlugin(String artifactId, @CheckForNull VersionNumber minVersion)
UpdateSite
to contain it.UpdateSite.Plugin
. null
if it cannot be found@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) @NonNull public List<UpdateSite.Plugin> getPluginFromAllSites(String artifactId, @CheckForNull VersionNumber minVersion)
public void doUpgrade(org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public org.kohsuke.stapler.HttpResponse doInvalidateData()
public void doSafeRestart(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doCancelRestart(org.kohsuke.stapler.StaplerResponse response) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
@Exported public boolean isRestartRequiredForCompletion()
UpdateCenter.UpdateCenterJob
s requires a restart
to take effect, this method returns true.
This doesn't necessarily mean the user has scheduled or initiated the restart operation.
isRestartScheduled()
public boolean isRestartScheduled()
isRestartRequiredForCompletion()
public boolean isDowngradable()
public void doDowngrade(org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public void doRestart(org.kohsuke.stapler.StaplerResponse rsp) throws IOException, javax.servlet.ServletException
IOException
javax.servlet.ServletException
public String getBackupVersion()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Future<UpdateCenter.UpdateCenterJob> addJob(UpdateCenter.UpdateCenterJob job)
public String getDisplayName()
getDisplayName
in interface ModelObject
public String getSearchUrl()
SearchItem
SearchItem
.getSearchUrl
in interface SearchItem
public void save()
public void load() throws IOException
IOException
protected UpdateSite createDefaultUpdateSite()
@Exported public List<UpdateSite.Plugin> getAvailables()
@Deprecated public UpdateCenter.PluginEntry[] getCategorizedAvailables()
getAvailables()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static String getCategoryDisplayName(String category)
public List<UpdateSite.Plugin> getUpdates()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public List<UpdateSite.Plugin> getPluginsWithUnavailableUpdates()
public List<FormValidation> updateAllSites() throws InterruptedException, ExecutionException
FormValidation
for each updated Update SiteInterruptedException
ExecutionException
@Initializer(after=PLUGINS_STARTED, fatal=false) public static void init(Jenkins h) throws IOException
IOException
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void updateAllSitesNow()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public static void updateDefaultSite()
@Restricted(value=org.kohsuke.accmod.restrictions.NoExternalUse.class) public Object getTarget()
getTarget
in interface org.kohsuke.stapler.StaplerProxy
Copyright © 2004–2022. All rights reserved.