Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JENKINS_UC_DOWNLOAD_URL if provided #416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,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 @@ -1184,8 +1186,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 @@ -1182,7 +1182,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 @@ -1198,7 +1198,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 @@ -1214,13 +1214,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