/** * Initializes the update center. * * This has to wait until after all plugins load, to let custom UpdateCenterConfiguration take effect first. */ @Initializer(after=PLUGINS_STARTED, fatal=false) public static void init(Jenkins h) throws IOException { h.getUpdateCenter().load(); }
/** * URL to download. */ public String getUrl() { return Jenkins.getInstance().getUpdateCenter().getDefaultBaseUrl()+"updates/"+url; }
/** * URLs to download from. */ public List<String> getUrls() { List<String> updateSites = new ArrayList<String>(); for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) { String siteUrl = site.getUrl(); int baseUrlEnd = siteUrl.indexOf("update-center.json"); if (baseUrlEnd != -1) { String siteBaseUrl = siteUrl.substring(0, baseUrlEnd); updateSites.add(siteBaseUrl + "updates/" + url); } else { LOGGER.log(Level.WARNING, "Url {0} does not look like an update center:", siteUrl); } } return updateSites; }
@Nonnull public Set<UpdateSite.Warning> getAllWarnings() { HashSet<UpdateSite.Warning> allWarnings = new HashSet<>(); for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) { UpdateSite.Data data = site.getData(); if (data != null) { allWarnings.addAll(data.getWarnings()); } } return allWarnings; }
public Data getData() { UpdateSite cs = Jenkins.getInstance().getUpdateCenter().getCoreSource(); if (cs!=null) return cs.getData(); return null; } }
@Restricted(NoExternalUse.class) public static void updateDefaultSite() { final UpdateSite site = Jenkins.getInstance().getUpdateCenter().getSite(UpdateCenter.ID_DEFAULT); if (site == null) { LOGGER.log(Level.SEVERE, "Upgrading Jenkins. Cannot retrieve the default Update Site ''{0}''. " + "Plugin installation may fail.", UpdateCenter.ID_DEFAULT); return; } try { // Need to do the following because the plugin manager will attempt to access // $JENKINS_HOME/updates/$ID_DEFAULT.json. Needs to be up to date. site.updateDirectlyNow(true); } catch (Exception e) { LOGGER.log(WARNING, "Upgrading Jenkins. Failed to update the default Update Site '" + UpdateCenter.ID_DEFAULT + "'. Plugin upgrades may fail.", e); } }
/** * Update the data file from the given URL if the file * does not exist, or is otherwise due for update. * Accepted formats are JSONP or HTML with {@code postMessage}, not raw JSON. * @param signatureCheck whether to enforce the signature (may be off only for testing!) * @return null if no updates are necessary, or the future result * @since 1.502 */ public @CheckForNull Future<FormValidation> updateDirectly(final boolean signatureCheck) { if (! getDataFile().exists() || isDue()) { return Jenkins.getInstance().getUpdateCenter().updateService.submit(new Callable<FormValidation>() { @Override public FormValidation call() throws Exception { return updateDirectlyNow(signatureCheck); } }); } else { return null; } }
updateSiteList: for (UpdateSite updateSite : Jenkins.get().getUpdateCenter().getSiteList()) { String updateCenterJsonUrl = updateSite.getUrl(); String suggestedPluginUrl = updateCenterJsonUrl.replace("/update-center.json", "/platform-plugins.json");
Plugin depPlugin = Jenkins.getInstance().getUpdateCenter().getPlugin(e.getKey(), requiredVersion); if (depPlugin == null) { LOGGER.log(Level.WARNING, "Could not find dependency {0} of {1}", new Object[] {e.getKey(), name}); Plugin depPlugin = Jenkins.getInstance().getUpdateCenter().getPlugin(e.getKey(), requiredVersion); if (depPlugin == null) { continue;
private UpdateSite.Plugin getPlugin(String pluginName, String siteName) { UpdateSite updateSite = Jenkins.getInstance().getUpdateCenter().getById(siteName); if (updateSite == null) { throw new Failure("No such update center: " + siteName); } return updateSite.getPlugin(pluginName); }
private FormValidation checkUpdatesServer() throws Exception { for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) { FormValidation v = site.updateDirectlyNow(DownloadService.signatureCheck); if (v.kind != FormValidation.Kind.OK) { // Stop with an error return v; } } for (DownloadService.Downloadable d : DownloadService.Downloadable.all()) { FormValidation v = d.updateNow(); if (v.kind != FormValidation.Kind.OK) { // Stop with an error return v; } } return FormValidation.ok(); }
List<JSONObject> jsonList = new ArrayList<>(); boolean toolInstallerMetadataExists = false; for (UpdateSite updatesite : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) { String site = updatesite.getMetadataUrlForDownloadable(url); if (site == null) {
/** * Bare-minimum configuration mechanism to change the update center. */ @RequirePOST public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException { Jenkins hudson = Jenkins.getInstance(); hudson.checkPermission(CONFIGURE_UPDATECENTER); UpdateCenter uc = hudson.getUpdateCenter(); PersistedList<UpdateSite> sites = uc.getSites(); for (UpdateSite s : sites) { if (s.getId().equals(UpdateCenter.ID_DEFAULT)) sites.remove(s); } sites.add(new UpdateSite(UpdateCenter.ID_DEFAULT, site)); return new HttpRedirect("advanced"); }
/** * returns the {@link hudson.model.UpdateSite.Plugin} object, or null. */ public UpdateSite.Plugin getInfo() { UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); UpdateSite.Plugin p = uc.getPlugin(getShortName(), getVersionNumber()); if (p != null) return p; return uc.getPlugin(getShortName()); }
/** * Schedules the downgrade of this plugin. */ public Future<UpdateCenterJob> deployBackup() { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); return uc.addJob(uc.new PluginDowngradeJob(this, UpdateSite.this, Jenkins.getAuthentication())); } /**
/** * If the plugin has {@link #getUpdateInfo() an update}, * returns the {@link hudson.model.UpdateSite.Plugin} object. * * @return * This method may return null — for example, * the user may have installed a plugin locally developed. */ public UpdateSite.Plugin getUpdateInfo() { UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); UpdateSite.Plugin p = uc.getPlugin(getShortName(), getVersionNumber()); if(p!=null && p.isNewerThan(getVersion())) return p; return null; }
/** * Returns whether the system needs a restart, and if it is supported * e.g. { restartRequired: true, restartSupported: false } */ @Restricted(DoNotUse.class) // WebOnly public HttpResponse doRestartStatus() throws IOException { JSONObject response = new JSONObject(); Jenkins jenkins = Jenkins.get(); response.put("restartRequired", jenkins.getUpdateCenter().isRestartRequiredForCompletion()); response.put("restartSupported", jenkins.getLifecycle().canRestart()); return HttpResponses.okJSON(response); }
for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) { if (site.isDue()) { due = true;
public Future<UpdateCenterJob> deploy(boolean dynamicLoad, @CheckForNull UUID correlationId) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); for (Plugin dep : getNeededDependencies()) { UpdateCenter.InstallationJob job = uc.getJob(dep);
@RequirePOST public HttpResponse doUpdateSources(StaplerRequest req) throws IOException { Jenkins.getInstance().checkPermission(CONFIGURE_UPDATECENTER); if (req.hasParameter("remove")) { UpdateCenter uc = Jenkins.getInstance().getUpdateCenter(); BulkChange bc = new BulkChange(uc); try { for (String id : req.getParameterValues("sources")) uc.getSites().remove(uc.getById(id)); } finally { bc.commit(); } } else if (req.hasParameter("add")) return new HttpRedirect("addSite"); return new HttpRedirect("./sites"); }