Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-28466

Can't use environment variables like JENKINS_URL、JOB_URL、BUILD_URL in a new jenkins before it's save-button which is in system settings is clicked

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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?

        Attachments

          Issue Links

            Activity

            Hide
            laffoyb Barry Laffoy added a comment -

            Alex Earl, 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.

            Show
            laffoyb Barry Laffoy added a comment - Alex Earl , 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.
            Hide
            cweaver Chris Weaver added a comment -

            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".

            Show
            cweaver Chris Weaver added a comment - 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".
            Hide
            markewaite Mark Waite added a comment -

            Chris Weaver, 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 Barry Laffoy 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.

            Show
            markewaite Mark Waite added a comment - Chris Weaver , 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 Barry Laffoy 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.
            Hide
            chahal Pardeep Chahal added a comment - - edited

            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:

            1. 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. 
            2. 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.
            3. To fix it during installation, follow steps mentioned by Mark Waite
            4. Create JENKINS_HOME/data/jenkins.model.JenkinsLocationConfiguration.xml and add below contents
            5. <?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>

            Show
            chahal Pardeep Chahal added a comment - - edited 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 Mark Waite .  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>
            Hide
            danielbeck Daniel Beck added a comment -

            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.

            Show
            danielbeck Daniel Beck added a comment - 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.

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              hz_tc liu yecheng
              Votes:
              3 Vote for this issue
              Watchers:
              12 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: