Package hudson.model

Class UpdateCenter

    • Field Detail

      • ID_DEFAULT

        public static final String ID_DEFAULT
        ID of the default update site.
        Since:
        1.483; configurable via system property since 2.4
      • ID_UPLOAD

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static final String ID_UPLOAD
        See Also:
        Constant Field Values
      • SKIP_PERMISSION_CHECK

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static boolean SKIP_PERMISSION_CHECK
        Escape hatch for StaplerProxy-based access control
      • XSTREAM

        public static final XStream2 XSTREAM
    • Constructor Detail

      • UpdateCenter

        public UpdateCenter()
    • Method Detail

      • createUpdateCenter

        @NonNull
        public static UpdateCenter createUpdateCenter​(@CheckForNull
                                                      UpdateCenter.UpdateCenterConfiguration config)
        Creates an update center.
        Parameters:
        config - Requested configuration. May be null if defaults should be used
        Returns:
        Created Update center. UpdateCenter by default, but may be overridden
        Since:
        2.4
      • getApi

        public Api getApi()
      • getBadge

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public Badge getBadge()
      • doConnectionStatus

        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        public org.kohsuke.stapler.HttpResponse doConnectionStatus​(org.kohsuke.stapler.StaplerRequest request)
        Get the current connection status.

        Supports a "siteId" request parameter, defaulting to ID_DEFAULT for the default update site.

        Returns:
        The current connection status.
      • doIncompleteInstallStatus

        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        public org.kohsuke.stapler.HttpResponse doIncompleteInstallStatus()
        Called to determine if there was an incomplete installation, what the statuses of the plugins are
      • persistInstallStatus

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public void persistInstallStatus()
        Called to persist the currently installing plugin states. This allows us to support install resume if Jenkins is restarted while plugins are being installed.
      • doInstallStatus

        @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class)
        public org.kohsuke.stapler.HttpResponse doInstallStatus​(org.kohsuke.stapler.StaplerRequest request)
        Get the current installation status of a plugin set.

        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).

        Returns:
        The current installation status of a plugin set.
      • getHudsonJob

        public UpdateCenter.HudsonUpgradeJob getHudsonJob()
        Returns latest Jenkins upgrade job.
        Returns:
        HudsonUpgradeJob or null if not found
      • getSites

        @StaplerDispatchable
        public PersistedList<UpdateSite> getSites()
        Returns the list of UpdateSites to be used. This is a live list, whose change will be persisted automatically.
        Returns:
        can be empty but never null.
      • isSiteDataReady

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public boolean isSiteDataReady()
        Whether it is probably safe to call all UpdateSite.getData() without blocking.
        Returns:
        true if all data is currently ready (or absent); false if some is not ready now (but it will be loaded in the background)
      • getLastUpdatedString

        public String getLastUpdatedString()
        Gets the string representing how long ago the data was obtained. Will be the newest of all UpdateSites.
      • getById

        @CheckForNull
        public UpdateSite getById​(String id)
        Gets UpdateSite by its ID. Used to bind them to URL.
        Parameters:
        id - ID of the update site to be retrieved
        Returns:
        Discovered UpdateSite. null if it cannot be found
      • getCoreSource

        @CheckForNull
        public UpdateSite getCoreSource()
        Gets the UpdateSite from which we receive updates for jenkins.war.
        Returns:
        null if no such update center is provided.
      • getDefaultBaseUrl

        @Deprecated
        public 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.
        Gets the default base URL.
      • getPluginFromAllSites

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        @NonNull
        public List<UpdateSite.Plugin> getPluginFromAllSites​(String artifactId,
                                                             @CheckForNull
                                                             VersionNumber minVersion)
        Gets plugin info from all available sites
        Returns:
        list of plugins
      • doUpgrade

        public void doUpgrade​(org.kohsuke.stapler.StaplerResponse rsp)
                       throws IOException,
                              javax.servlet.ServletException
        Schedules a Jenkins upgrade.
        Throws:
        IOException
        javax.servlet.ServletException
      • doInvalidateData

        public org.kohsuke.stapler.HttpResponse doInvalidateData()
        Invalidates the update center JSON data for all the sites and force re-retrieval.
        Since:
        1.432
      • doSafeRestart

        public void doSafeRestart​(org.kohsuke.stapler.StaplerRequest request,
                                  org.kohsuke.stapler.StaplerResponse response)
                           throws IOException,
                                  javax.servlet.ServletException
        Schedules a Jenkins restart.
        Throws:
        IOException
        javax.servlet.ServletException
      • doCancelRestart

        public void doCancelRestart​(org.kohsuke.stapler.StaplerResponse response)
                             throws IOException,
                                    javax.servlet.ServletException
        Cancel all scheduled jenkins restarts
        Throws:
        IOException
        javax.servlet.ServletException
      • isRestartRequiredForCompletion

        @Exported
        public boolean isRestartRequiredForCompletion()
        If any of the executed UpdateCenter.UpdateCenterJobs requires a restart to take effect, this method returns true.

        This doesn't necessarily mean the user has scheduled or initiated the restart operation.

        See Also:
        isRestartScheduled()
      • isRestartScheduled

        public boolean isRestartScheduled()
        Checks if the restart operation is scheduled (which means in near future Jenkins will restart by itself)
        See Also:
        isRestartRequiredForCompletion()
      • isDowngradable

        public boolean isDowngradable()
        Returns true if backup of jenkins.war exists on the hard drive
      • doDowngrade

        public void doDowngrade​(org.kohsuke.stapler.StaplerResponse rsp)
                         throws IOException,
                                javax.servlet.ServletException
        Performs hudson downgrade.
        Throws:
        IOException
        javax.servlet.ServletException
      • doRestart

        public void doRestart​(org.kohsuke.stapler.StaplerResponse rsp)
                       throws IOException,
                              javax.servlet.ServletException
        Performs hudson downgrade.
        Throws:
        IOException
        javax.servlet.ServletException
      • getBackupVersion

        public String getBackupVersion()
        Returns String with version of backup .war file, if the file does not exists returns null
      • getSearchUrl

        public String getSearchUrl()
        Description copied from interface: SearchItem
        Returns the URL of this item relative to the parent SearchItem.
        Specified by:
        getSearchUrl in interface SearchItem
        Returns:
        URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
      • save

        public void save()
        Saves the configuration info to the disk.
        Specified by:
        save in interface Saveable
      • load

        public void load()
                  throws IOException
        Loads the data from the disk into this object.
        Specified by:
        load in interface Loadable
        Throws:
        IOException - The state could not be loaded.
      • createDefaultUpdateSite

        protected UpdateSite createDefaultUpdateSite()
      • getCategorizedAvailables

        @Deprecated
        public UpdateCenter.PluginEntry[] getCategorizedAvailables()
        Deprecated.
        Returns a list of plugins that should be shown in the "available" tab, grouped by category. A plugin with multiple categories will appear multiple times in the list.
      • getCategoryDisplayName

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static String getCategoryDisplayName​(String category)
      • hasIncompatibleUpdates

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public boolean hasIncompatibleUpdates​(PluginManager.MetadataCache cache)
      • updateAllSitesNow

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static void updateAllSitesNow()
      • updateDefaultSite

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public static void updateDefaultSite()
      • getTarget

        @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
        public Object getTarget()
        Specified by:
        getTarget in interface org.kohsuke.stapler.StaplerProxy