jenkinsci / nomad-plugin

Nomad cloud plugin for Jenkins
https://plugins.jenkins.io/nomad/
MIT License
56 stars 41 forks source link

Get jenkins URL dynamically #161

Closed Kamilcuk closed 1 year ago

Kamilcuk commented 1 year ago

What feature do you want to see added?

Please add two new template parameters: %JENKINS_URL% and %JENKINS_TUNNEL% that will be replaced by jenkins.getRootUrl() and by new URL(jenkins.getRootUrl()).getHost() + ":50000" respectively.

Jenkins already knows the URL, there is no need to fill it manually. This would enhance portability of templates between our multiple Jenkins instances.

Upstream changes

No response

j3t commented 1 year ago

jenkins.getRootUrl() can be empty. The tunnel host is not necessarily the same as new URL(jenkins.getRootUrl()).getHost() and the port could also be anything (e.g. Jenkins runs behind a load balancer, reverse proxy, etc.).

What is your use case? Is CaaS not an option?

Vaelatern commented 1 year ago

If you are running Jenkins in Nomad, dynamically placing the instance (and the port it's listening to) then it would help to have the ${NOMAD_ADDR_http} (or whatever the port is named) available in the template. Environment variables visible to the Jenkins host are not currently available to the template.

I'm using CaaS and several other "Jenkins consistent configuration as code" plugins.