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

JENKINS_UC_DOWNLOAD_URL usage logic incorrect #415

Open
nhojpatrick opened this issue Mar 10, 2022 · 9 comments · May be fixed by #416
Open

JENKINS_UC_DOWNLOAD_URL usage logic incorrect #415

nhojpatrick opened this issue Mar 10, 2022 · 9 comments · May be fixed by #416
Labels
bug Something isn't working

Comments

@nhojpatrick
Copy link
Contributor

Jenkins and plugins versions report

Environment

jenkins-plugin-manager-2.13.0.jar

What Operating System are you using (both controller, and any agents involved in the problem)?

n/a

Reproduction steps

  1. ENV JENKINS_UC_DOWNLOAD_URL http://localhost:8080/jenkins
  2. RUN jenkins-plugin-cli --plugins my-plugin:1.2.3

Expected Results

Download attempt from;
http://localhost:8080/jenkins/my-plugin/1.2.3/my-plugin.hpi

Actual Results

Download attempt from;
https://updates.jenkins.io/download/plugins/my-plugin/1.2.3/my-plugin.hpi

Anything else?

No response

@nhojpatrick nhojpatrick added the bug Something isn't working label Mar 10, 2022
nhojpatrick added a commit to nhojpatrick/jenkinsci_plugin-installation-manager-tool that referenced this issue Mar 10, 2022
@nhojpatrick nhojpatrick linked a pull request Mar 10, 2022 that will close this issue
6 tasks
@nhojpatrick
Copy link
Contributor Author

Fixing the same issue as highlighted here jenkinsci/docker#1299

nhojpatrick added a commit to nhojpatrick/jenkinsci_plugin-installation-manager-tool that referenced this issue Mar 10, 2022
nhojpatrick added a commit to nhojpatrick/jenkinsci_plugin-installation-manager-tool that referenced this issue Mar 11, 2022
nhojpatrick added a commit to nhojpatrick/jenkinsci_plugin-installation-manager-tool that referenced this issue Mar 11, 2022
@juanmacoo
Copy link
Contributor

I don't understand this change, this is exactly how it works after #375 .

@nhojpatrick
Copy link
Contributor Author

nhojpatrick commented Apr 14, 2022

I don't understand this change, this is exactly how it works after #375 .

That code doesn't appear to fully work in all situations.
Reading the code it looks like if pluginUrl is empty, then it uses jenkinsUcDownloadUrl.
But the update center json contains the pluginUrl, so it will always be present.

But I've just patched it locally so I'm good. I was just trying to help out others.

@juanmacoo
Copy link
Contributor

juanmacoo commented Apr 16, 2022

AH, no, I see what you did. My bad.

@cronik
Copy link
Contributor

cronik commented Jun 20, 2022

wouldn't the correct solution here to use my-plugin:1.2.3:http://localhost:8080/jenkins/my-plugin/1.2.3/my-plugin.hpi? The associated #416 seems to give precedence over and ignore the other download url configuration options like JENKINS_UC_EXPERIMENTAL and JENKINS_INCREMENTALS_REPO_MIRROR .

@ac-miller
Copy link

When I read the README, JENKINS_UC_DOWNLOAD_URL is listed as the way to download all of your plugins through a specific mirror. But the behavior of the code does not reflect this. Either the README needs to be updated or a solution like #416 would be better.

From the README:

When this value is set, it replaces the plugin download URL found in the update-center.json file with ${JENKINS_UC_DOWNLOAD_URL}

It does not mention that there is also a check for existence of pluginUrl

@bordenit
Copy link

bordenit commented Nov 4, 2023

This is a very annoying issue if you want to download artifacts from Artifactory as well. If I pass in the Artifactory url it shouldn't slice my url, and then randomly append /download/plugins to it. It should accept the exact url at least up to the standard folder format for the plugin. What was the workaround if there is no fix?

@cronik
Copy link
Contributor

cronik commented Nov 4, 2023

Been using the plugin manage cli with Artifactory for a while using the following setup:

JENKINS_UC=https://artifactory.example.com/artifactory/jenkins-update-center/dynamic-stable-2.414.3/update-center.json
# don't really use these but set them anyway
JENKINS_UC_DOWNLOAD_URL=https://artifactory.example.com/artifactory/jenkins-update-center/download/plugins
JENKINS_UC_EXPERIMENTAL=https://artifactory.example.com/artifactory/jenkins-update-center/experimental/update-center.json
JENKINS_INCREMENTALS_REPO_MIRROR=https://artifactory.example.com/artifactory/jenkins-update-center/incrementals
JENKINS_PLUGIN_INFO=https://artifactory.example.com/artifactory/jenkins-update-center/current/plugin-versions.json

If a custom plugin is required it happens on per plugin override basis in the plugins spec. The provided download url overrides all other UC configurations.

my-plugin:1.2.3:https://artifactory.example.com/artifactory/jenkins-plugins-generic-local/my-plugin/1.2.3/my-plugin.hpi

Note that Artifactory doesn't support the dynamic plugin folder resolution that the plugin manager attempts to perform so we have to resolve it first and explicitly include it in the JENKINS_UC path. This can be done with the following script.

https updates.jenkins.io/update-center.json version==${LTS_VERSION} -h | grep Location

Another issue with Artifactory is once it caches update-center.json it never downloads it again so you end up with a point-in-time snapshot. You either need to delete the cached file (zap doesn't help) or use some Artifactory plugin to refresh it (see RTFACT-12556). We typically prefer the point-in-time snapshot since we build docker images and it provides a stable plugin set between LTS releases.

Artifactory generic repository cache characteristics combined with Jenkins dynamic plugin folders definitely make this whole process a bear, but it is possible.

Hope this helps.

@bordenit
Copy link

bordenit commented Nov 11, 2023

Thanks. I just set JENKINS_UC_DOWNLOAD to https://artifactory.example.com/artifactory/ and created a virtual repo from there at the default path to my Jenkins plugin remote repo. I'm fine with it querying the internet for the plugin-versions.json and update-center.json, just want it to scan the plugin downloads with X-ray.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants