Status: Closed (View Workflow)
Jenkins ver. 1.592
when I start to use a new Jenkins, some environment variables like JENKINS_URL、JOB_URL、BUILD_URL can't be used.But when I click the save-button in system settings ,those environment variables works.So i doubt is it right?
JENKINS-31661 Jenkins.rootUrl too often unset or incorrect
I have the same problem for the same reasons (fully automating a Jenkins install) and I still don't understand how this is not a bug. I see a configuration page that is full of configuration, but only half of it is actually in the system until I click "Save". So how can I trust the information on this page? Or any page?
There must be a better solution than "go through every configuration page clicking Save as soon as Jenkins comes up".
cweaver, no one suggested that anyone needs to
go through every configuration page clicking Save as soon as Jenkins comes up
The JENKINS_URL needs to be configured before it can be returned. It is configured through the XML file jenkins.model.JenkinsLocationConfiguration.xml or through the groovy script that laffoyb provided in an earlier comment.
I use the XML file in a private copy of my Docker image. It has worked very well for me automating deployment to multiple machines in multiple environments.
We struggled for two days to find out this issue. Thanks for the help. Our Jenkins version is 2.85 and I am not sure if this issue works fine in older versions or not.
To replicate and fix this issue, please follow the below steps:
- Jenkins_URL or Jenkins parameters values must be coming null when you launch a fresh instance of Jenkins and trying to trigger some automation jobs, which uses environment variables.
- To fix issue manually, Go to Manage Jenkins -> Configure System -> Save settings (without making any change). This should fix the issue if you are doing Jenkins configuration manually.
- To fix it during installation, follow steps mentioned by markewaite .
- Create JENKINS_HOME/data/jenkins.model.JenkinsLocationConfiguration.xml and add below contents
- <?xml version='1.0' encoding='UTF-8'?>
<jenkins.model.JenkinsLocationConfiguration> <adminAddress>address not configured yet <nobody@nowhere></adminAddress> <jenkinsUrl>JENKINS_URL_VALUE/</jenkinsUrl></jenkins.model.JenkinsLocationConfiguration>
Fix in progress (admin monitor if it's unset, and adding it to the setup wizard) in the context of
JENKINS-31661 so resolving as duplicate. The issues are related enough.
slide_o_mix, I will bear that in mind. It's likely that every issue I want to file can be summarised as "Why can't I configure <something> with an environment variable and/or a configuration file to aid automation?"
On this topic, even if the current behaviour of JENKINS_URL isn't being considered a bug, I think that the fact that the config settings screen is actively misleading to users should be considered one. Either the field should not be populated from the HTTP context of the request, or it should be clearly marked as a suggestion that has not actually been added to Jenkins' configuration.