jenkins.model.Jenkins.getUpdateCenter()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(193)

本文整理了Java中jenkins.model.Jenkins.getUpdateCenter()方法的一些代码示例,展示了Jenkins.getUpdateCenter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getUpdateCenter()方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getUpdateCenter

Jenkins.getUpdateCenter介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Initializes the update center.
  3. *
  4. * This has to wait until after all plugins load, to let custom UpdateCenterConfiguration take effect first.
  5. */
  6. @Initializer(after=PLUGINS_STARTED, fatal=false)
  7. public static void init(Jenkins h) throws IOException {
  8. h.getUpdateCenter().load();
  9. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * URL to download.
  3. */
  4. public String getUrl() {
  5. return Jenkins.getInstance().getUpdateCenter().getDefaultBaseUrl()+"updates/"+url;
  6. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * URLs to download from.
  3. */
  4. public List<String> getUrls() {
  5. List<String> updateSites = new ArrayList<String>();
  6. for (UpdateSite site : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) {
  7. String siteUrl = site.getUrl();
  8. int baseUrlEnd = siteUrl.indexOf("update-center.json");
  9. if (baseUrlEnd != -1) {
  10. String siteBaseUrl = siteUrl.substring(0, baseUrlEnd);
  11. updateSites.add(siteBaseUrl + "updates/" + url);
  12. } else {
  13. LOGGER.log(Level.WARNING, "Url {0} does not look like an update center:", siteUrl);
  14. }
  15. }
  16. return updateSites;
  17. }

代码示例来源:origin: jenkinsci/jenkins

  1. @Nonnull
  2. public Set<UpdateSite.Warning> getAllWarnings() {
  3. HashSet<UpdateSite.Warning> allWarnings = new HashSet<>();
  4. for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) {
  5. UpdateSite.Data data = site.getData();
  6. if (data != null) {
  7. allWarnings.addAll(data.getWarnings());
  8. }
  9. }
  10. return allWarnings;
  11. }

代码示例来源:origin: jenkinsci/jenkins

  1. public Data getData() {
  2. UpdateSite cs = Jenkins.getInstance().getUpdateCenter().getCoreSource();
  3. if (cs!=null) return cs.getData();
  4. return null;
  5. }
  6. }

代码示例来源:origin: jenkinsci/jenkins

  1. @Restricted(NoExternalUse.class)
  2. public static void updateDefaultSite() {
  3. final UpdateSite site = Jenkins.getInstance().getUpdateCenter().getSite(UpdateCenter.ID_DEFAULT);
  4. if (site == null) {
  5. LOGGER.log(Level.SEVERE, "Upgrading Jenkins. Cannot retrieve the default Update Site ''{0}''. "
  6. + "Plugin installation may fail.", UpdateCenter.ID_DEFAULT);
  7. return;
  8. }
  9. try {
  10. // Need to do the following because the plugin manager will attempt to access
  11. // $JENKINS_HOME/updates/$ID_DEFAULT.json. Needs to be up to date.
  12. site.updateDirectlyNow(true);
  13. } catch (Exception e) {
  14. LOGGER.log(WARNING, "Upgrading Jenkins. Failed to update the default Update Site '" + UpdateCenter.ID_DEFAULT +
  15. "'. Plugin upgrades may fail.", e);
  16. }
  17. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Update the data file from the given URL if the file
  3. * does not exist, or is otherwise due for update.
  4. * Accepted formats are JSONP or HTML with {@code postMessage}, not raw JSON.
  5. * @param signatureCheck whether to enforce the signature (may be off only for testing!)
  6. * @return null if no updates are necessary, or the future result
  7. * @since 1.502
  8. */
  9. public @CheckForNull Future<FormValidation> updateDirectly(final boolean signatureCheck) {
  10. if (! getDataFile().exists() || isDue()) {
  11. return Jenkins.getInstance().getUpdateCenter().updateService.submit(new Callable<FormValidation>() {
  12. @Override public FormValidation call() throws Exception {
  13. return updateDirectlyNow(signatureCheck);
  14. }
  15. });
  16. } else {
  17. return null;
  18. }
  19. }

代码示例来源:origin: jenkinsci/jenkins

  1. updateSiteList: for (UpdateSite updateSite : Jenkins.get().getUpdateCenter().getSiteList()) {
  2. String updateCenterJsonUrl = updateSite.getUrl();
  3. String suggestedPluginUrl = updateCenterJsonUrl.replace("/update-center.json", "/platform-plugins.json");

代码示例来源:origin: jenkinsci/jenkins

  1. Plugin depPlugin = Jenkins.getInstance().getUpdateCenter().getPlugin(e.getKey(), requiredVersion);
  2. if (depPlugin == null) {
  3. LOGGER.log(Level.WARNING, "Could not find dependency {0} of {1}", new Object[] {e.getKey(), name});
  4. Plugin depPlugin = Jenkins.getInstance().getUpdateCenter().getPlugin(e.getKey(), requiredVersion);
  5. if (depPlugin == null) {
  6. continue;

代码示例来源:origin: jenkinsci/jenkins

  1. private UpdateSite.Plugin getPlugin(String pluginName, String siteName) {
  2. UpdateSite updateSite = Jenkins.getInstance().getUpdateCenter().getById(siteName);
  3. if (updateSite == null) {
  4. throw new Failure("No such update center: " + siteName);
  5. }
  6. return updateSite.getPlugin(pluginName);
  7. }

代码示例来源:origin: jenkinsci/jenkins

  1. private FormValidation checkUpdatesServer() throws Exception {
  2. for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) {
  3. FormValidation v = site.updateDirectlyNow(DownloadService.signatureCheck);
  4. if (v.kind != FormValidation.Kind.OK) {
  5. // Stop with an error
  6. return v;
  7. }
  8. }
  9. for (DownloadService.Downloadable d : DownloadService.Downloadable.all()) {
  10. FormValidation v = d.updateNow();
  11. if (v.kind != FormValidation.Kind.OK) {
  12. // Stop with an error
  13. return v;
  14. }
  15. }
  16. return FormValidation.ok();
  17. }

代码示例来源:origin: jenkinsci/jenkins

  1. List<JSONObject> jsonList = new ArrayList<>();
  2. boolean toolInstallerMetadataExists = false;
  3. for (UpdateSite updatesite : Jenkins.getActiveInstance().getUpdateCenter().getSiteList()) {
  4. String site = updatesite.getMetadataUrlForDownloadable(url);
  5. if (site == null) {

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Bare-minimum configuration mechanism to change the update center.
  3. */
  4. @RequirePOST
  5. public HttpResponse doSiteConfigure(@QueryParameter String site) throws IOException {
  6. Jenkins hudson = Jenkins.getInstance();
  7. hudson.checkPermission(CONFIGURE_UPDATECENTER);
  8. UpdateCenter uc = hudson.getUpdateCenter();
  9. PersistedList<UpdateSite> sites = uc.getSites();
  10. for (UpdateSite s : sites) {
  11. if (s.getId().equals(UpdateCenter.ID_DEFAULT))
  12. sites.remove(s);
  13. }
  14. sites.add(new UpdateSite(UpdateCenter.ID_DEFAULT, site));
  15. return new HttpRedirect("advanced");
  16. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * returns the {@link hudson.model.UpdateSite.Plugin} object, or null.
  3. */
  4. public UpdateSite.Plugin getInfo() {
  5. UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
  6. UpdateSite.Plugin p = uc.getPlugin(getShortName(), getVersionNumber());
  7. if (p != null) return p;
  8. return uc.getPlugin(getShortName());
  9. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Schedules the downgrade of this plugin.
  3. */
  4. public Future<UpdateCenterJob> deployBackup() {
  5. Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  6. UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
  7. return uc.addJob(uc.new PluginDowngradeJob(this, UpdateSite.this, Jenkins.getAuthentication()));
  8. }
  9. /**

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * If the plugin has {@link #getUpdateInfo() an update},
  3. * returns the {@link hudson.model.UpdateSite.Plugin} object.
  4. *
  5. * @return
  6. * This method may return null &mdash; for example,
  7. * the user may have installed a plugin locally developed.
  8. */
  9. public UpdateSite.Plugin getUpdateInfo() {
  10. UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
  11. UpdateSite.Plugin p = uc.getPlugin(getShortName(), getVersionNumber());
  12. if(p!=null && p.isNewerThan(getVersion())) return p;
  13. return null;
  14. }

代码示例来源:origin: jenkinsci/jenkins

  1. /**
  2. * Returns whether the system needs a restart, and if it is supported
  3. * e.g. { restartRequired: true, restartSupported: false }
  4. */
  5. @Restricted(DoNotUse.class) // WebOnly
  6. public HttpResponse doRestartStatus() throws IOException {
  7. JSONObject response = new JSONObject();
  8. Jenkins jenkins = Jenkins.get();
  9. response.put("restartRequired", jenkins.getUpdateCenter().isRestartRequiredForCompletion());
  10. response.put("restartSupported", jenkins.getLifecycle().canRestart());
  11. return HttpResponses.okJSON(response);
  12. }

代码示例来源:origin: jenkinsci/jenkins

  1. for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) {
  2. if (site.isDue()) {
  3. due = true;

代码示例来源:origin: jenkinsci/jenkins

  1. public Future<UpdateCenterJob> deploy(boolean dynamicLoad, @CheckForNull UUID correlationId) {
  2. Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  3. UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
  4. for (Plugin dep : getNeededDependencies()) {
  5. UpdateCenter.InstallationJob job = uc.getJob(dep);

代码示例来源:origin: jenkinsci/jenkins

  1. @RequirePOST
  2. public HttpResponse doUpdateSources(StaplerRequest req) throws IOException {
  3. Jenkins.getInstance().checkPermission(CONFIGURE_UPDATECENTER);
  4. if (req.hasParameter("remove")) {
  5. UpdateCenter uc = Jenkins.getInstance().getUpdateCenter();
  6. BulkChange bc = new BulkChange(uc);
  7. try {
  8. for (String id : req.getParameterValues("sources"))
  9. uc.getSites().remove(uc.getById(id));
  10. } finally {
  11. bc.commit();
  12. }
  13. } else
  14. if (req.hasParameter("add"))
  15. return new HttpRedirect("addSite");
  16. return new HttpRedirect("./sites");
  17. }

相关文章

Jenkins类方法