From 824f64c23e52e5c765cc7604414740aab3436f8d Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Sun, 18 Feb 2024 09:17:50 +0100 Subject: [PATCH] Allow update sites to define a custom URL for wizard plugin suggestion (#8951) * currently suggested plugins list as setup time is hardcoded, we can make it configurable Signed-off-by: Olivier Lamy * add new method to UpdateSite to avoid using System property Signed-off-by: Olivier Lamy * Update core/src/main/java/hudson/model/UpdateSite.java Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com> --------- Signed-off-by: Olivier Lamy Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com> Co-authored-by: Alexander Brandes --- core/src/main/java/hudson/model/UpdateSite.java | 11 +++++++++++ core/src/main/java/jenkins/install/SetupWizard.java | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 1b5b734c7be6..eb7f0f9679fb 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -493,6 +493,17 @@ public String getUrl() { return url; } + /** + * + * @return the URL used by {@link jenkins.install.SetupWizard} for suggested plugins to install at setup time + * @since TODO + */ + @Exported + public String getSuggestedPluginsUrl() { + String updateCenterJsonUrl = getUrl(); + return updateCenterJsonUrl.replace("/update-center.json", "/platform-plugins.json"); + } + /** * URL which exposes the metadata location in a specific update site. diff --git a/core/src/main/java/jenkins/install/SetupWizard.java b/core/src/main/java/jenkins/install/SetupWizard.java index 274b3a4ba663..19e63be1a837 100644 --- a/core/src/main/java/jenkins/install/SetupWizard.java +++ b/core/src/main/java/jenkins/install/SetupWizard.java @@ -553,8 +553,7 @@ public JSONArray getPlatformPluginUpdates() { Jenkins.get().checkPermission(Jenkins.ADMINISTER); JSONArray initialPluginList = null; updateSiteList: for (UpdateSite updateSite : Jenkins.get().getUpdateCenter().getSiteList()) { - String updateCenterJsonUrl = updateSite.getUrl(); - String suggestedPluginUrl = updateCenterJsonUrl.replace("/update-center.json", "/platform-plugins.json"); + String suggestedPluginUrl = updateSite.getSuggestedPluginsUrl(); VersionNumber version = Jenkins.getVersion(); if (version != null && (suggestedPluginUrl.startsWith("https://") || suggestedPluginUrl.startsWith("http://"))) { // Allow remote update site to distinguish based on the current version