Skip to content

Commit

Permalink
Use JENKINS_UC_DOWNLOAD_URL if provided (#416)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Waite <mark.earl.waite@gmail.com>
  • Loading branch information
nhojpatrick and MarkEWaite authored Oct 9, 2024
1 parent b48b0e4 commit b18bdd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,9 @@ public String getPluginDownloadUrl(Plugin plugin) {

String jenkinsUcDownload = System.getenv("JENKINS_UC_DOWNLOAD");
String jenkinsUcDownloadUrl = System.getenv("JENKINS_UC_DOWNLOAD_URL");
if (StringUtils.isNotEmpty(pluginUrl)) {
if (StringUtils.isNotEmpty(jenkinsUcDownloadUrl)) {
urlString = appendPathOntoUrl(jenkinsUcDownloadUrl, pluginName, pluginVersion, pluginName + ".hpi");
} else if (StringUtils.isNotEmpty(pluginUrl)) {
urlString = pluginUrl;
} else if (pluginVersion.equals(Plugin.LATEST) && !StringUtils.isEmpty(jenkinsUcLatest)) {
urlString = appendPathOntoUrl(dirName(jenkinsUcLatest), "/latest", pluginName + ".hpi");
Expand All @@ -1253,8 +1255,6 @@ public String getPluginDownloadUrl(Plugin plugin) {
groupId = groupId.replace(".", "/");
String incrementalsVersionPath = String.format("%s/%s/%s-%s.hpi", pluginName, pluginVersion, pluginName, pluginVersion);
urlString = appendPathOntoUrl(cfg.getJenkinsIncrementalsRepoMirror(), groupId, incrementalsVersionPath);
} else if (StringUtils.isNotEmpty(jenkinsUcDownloadUrl)) {
urlString = appendPathOntoUrl(jenkinsUcDownloadUrl, pluginName, pluginVersion, pluginName + ".hpi");
} else if (StringUtils.isNotEmpty(jenkinsUcDownload)) {
urlString = appendPathOntoUrl(jenkinsUcDownload, "/plugins", pluginName, pluginVersion, pluginName + ".hpi");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ public void getDownloadPluginUrlCustomUcUrls() throws IOException {
// lastest version
Plugin plugin = new Plugin("pluginName", "latest", null, null);
assertThat(pluginManager.getPluginDownloadUrl(plugin))
.isEqualTo("https://private-mirror.com/jenkins-updated-center/dynamic-stable-2.319.1/latest/pluginName.hpi");
.isEqualTo("https://private-mirror.com/jenkins-updated-center/download/plugins/pluginName/latest/pluginName.hpi");
},
() -> {
// latest version with resolved version
Expand All @@ -1365,7 +1365,7 @@ public void getDownloadPluginUrlCustomUcUrls() throws IOException {
// experimental version
Plugin plugin = new Plugin("pluginName", "experimental", null, null);
assertThat(pluginManager.getPluginDownloadUrl(plugin))
.isEqualTo("https://private-mirror.com/jenkins-updated-center/experimental/latest/pluginName.hpi");
.isEqualTo("https://private-mirror.com/jenkins-updated-center/download/plugins/pluginName/experimental/pluginName.hpi");
},
() -> {
// experimental version with resolved version
Expand All @@ -1381,13 +1381,13 @@ public void getDownloadPluginUrlCustomUcUrls() throws IOException {
// incremental
Plugin plugin = new Plugin("pluginName", "1.0.0", null, "com.cloudbees.jenkins");
assertThat(pluginManager.getPluginDownloadUrl(plugin))
.isEqualTo("https://private-mirror.com/jenkins-updated-center/incrementals/com/cloudbees/jenkins/pluginName/1.0.0/pluginName-1.0.0.hpi");
.isEqualTo("https://private-mirror.com/jenkins-updated-center/download/plugins/pluginName/1.0.0/pluginName.hpi");
},
() -> {
// explicit url
Plugin plugin = new Plugin("pluginName", "1.0.0", "https://other-mirror.com/plugins/custom-url.hpi", null);
assertThat(pluginManager.getPluginDownloadUrl(plugin))
.isEqualTo("https://other-mirror.com/plugins/custom-url.hpi");
.isEqualTo("https://private-mirror.com/jenkins-updated-center/download/plugins/pluginName/1.0.0/pluginName.hpi");
}
);
}
Expand Down

0 comments on commit b18bdd2

Please sign in to comment.