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

jenkins.model.JenkinsLocationConfiguration.xml is not set upon startup

      I'm using Jenkins within Openshift together with the stash notifier plugin. This plugin needs the jenkins rootURL to be set to work.

      When Jenkins starts (not only in openshift, but also native) the jenkins.model.JenkinsLocationConfiguration.xml is not saved automatically. and since this file does not exist Jenkins.getinstance().getRootUrl() returns null.

       

      When I enter the System Configuratiuon of jenkins, the root URL ist set in the GUI. After saving, the file jenkins.model.JenkinsLocationConfiguration.xml will be created.

       

      Also if I start a new Jenkins and create a Job, the file is created.

       

      When I work within Openshift the jobs are created from Openshift's BuildConfigs. But when these Jobs are created, the  jenkins.model.JenkinsLocationConfiguration.xml file does not exist and the root url is still null in any of these builds.

       

      There is also an Issue on redhats bugzilla about this: https://bugzilla.redhat.com/show_bug.cgi?id=1510908

          [JENKINS-48079] jenkins.model.JenkinsLocationConfiguration.xml is not set upon startup

          Gabe Montero added a comment -

          Commit

          8f2239062cc5eeed9ccd1fc2be62832e2190e8b0

          and v1.0.3 of the plugin provided the resolution for this issue.

          Gabe Montero added a comment - Commit 8f2239062cc5eeed9ccd1fc2be62832e2190e8b0 and v1.0.3 of the plugin provided the resolution for this issue.

          Marc Brugger added a comment -

          I've tested it with plugin version 1.0.7 in openshift-jenkins-2-rhel7:v3.9.14-2

           

          The Problem does still exist. The root URL is not set.

           

          [Pipeline] notifyBitbucket

          Cannot notify Stash! (Jenkins Root URL not configured)

          Marc Brugger added a comment - I've tested it with plugin version 1.0.7 in openshift-jenkins-2-rhel7:v3.9.14-2   The Problem does still exist. The root URL is not set.   [Pipeline] notifyBitbucket Cannot notify Stash! (Jenkins Root URL not configured)

          Gabe Montero added a comment -

          Did you explicitly configure it from the Jenkins console.

           

          That is the "fix"

          Gabe Montero added a comment - Did you explicitly configure it from the Jenkins console.   That is the "fix"

          Marc Brugger added a comment -

          What should I do to 'configure it from the jenkins console'?

          The fix commit is quite hard to read, since the whole file changed.

          https://github.com/jenkinsci/openshift-sync-plugin/compare/e1e2e2d05350...d3b43c767085

           

           

          Marc Brugger added a comment - What should I do to 'configure it from the jenkins console'? The fix commit is quite hard to read, since the whole file changed. https://github.com/jenkinsci/openshift-sync-plugin/compare/e1e2e2d05350...d3b43c767085    

          Gabe Montero added a comment - - edited

          Sorry, I got this bug confused with another one.

          I refreshed my memory with this and https://bugzilla.redhat.com/show_bug.cgi?id=1510908

          Yeah, there was no explicit intention to set the value in the jenkins.model.JenkinsLocationConfiguration.xml file from this plugin

          We did not want to override an settings the user might have made to that file via Jenkins configuration.

          or the jenkins service in OpenShift.

           

          I'll also not3 what jenkins.Model.Jenkins.getRootUrl() does:

           

              public @Nullable String getRootUrl() {
                  String url = JenkinsLocationConfiguration.get().getUrl();
                  if(url!=null) {
                      return Util.ensureEndsWith(url,"/");
                  }
                  StaplerRequest req = Stapler.getCurrentRequest();
                  if(req!=null)
                      return getRootUrlFromRequest();
                  return null;
              }

          And what the corresponding panel code does:

          f.section(title:_("Jenkins Location")) {
              f.entry(title:_("Jenkins URL"), field:"url") {
                  f.textbox(default: Functions.inferHudsonURL(request))
              }
              f.entry(title:_("System Admin e-mail address"), field:"adminAddress") {
                  f.textbox()
              }
          }

          So they take the request URI to infer an initial setting.  That is why you still see a value when you bring up that panel from our OpenShift Jenkins Image for example.

          As to changing from the Jenkins console (which is does store the changed version in that file)

          From "Manage Jenkins" -> "Configure System", you look for the "Jenkins Location" heading and the "Jenkins URL" field

           

          Then, the relevant piece of code is https://github.com/openshift/jenkins-sync-plugin/blob/master/src/main/java/io/fabric8/jenkins/openshiftsync/OpenShiftUtils.java#L448-L462

           

          If the root url from jenkins is set, per that jenkins.model.Jenkins code, we'll get the value from the xml file first.  It will use that before trying to discern from the service.

           

          You are free to open an RFE (not bug) to make such behavior configurable.

           

          thanks

          Gabe Montero added a comment - - edited Sorry, I got this bug confused with another one. I refreshed my memory with this and https://bugzilla.redhat.com/show_bug.cgi?id=1510908 Yeah, there was no explicit intention to set the value in the jenkins.model.JenkinsLocationConfiguration.xml file from this plugin We did not want to override an settings the user might have made to that file via Jenkins configuration. or the jenkins service in OpenShift.   I'll also not3 what jenkins.Model.Jenkins.getRootUrl() does:       public @Nullable String getRootUrl() {         String url = JenkinsLocationConfiguration.get().getUrl();         if(url!=null) {             return Util.ensureEndsWith(url,"/");         }         StaplerRequest req = Stapler.getCurrentRequest();         if(req!=null)             return getRootUrlFromRequest();         return null;     } And what the corresponding panel code does: f.section(title:_("Jenkins Location")) {     f.entry(title:_("Jenkins URL"), field:"url") {         f.textbox(default: Functions.inferHudsonURL(request))     }     f.entry(title:_("System Admin e-mail address"), field:"adminAddress") {         f.textbox()     } } So they take the request URI to infer an initial setting.  That is why you still see a value when you bring up that panel from our OpenShift Jenkins Image for example. As to changing from the Jenkins console (which is does store the changed version in that file) From "Manage Jenkins" -> "Configure System", you look for the "Jenkins Location" heading and the "Jenkins URL" field   Then, the relevant piece of code is https://github.com/openshift/jenkins-sync-plugin/blob/master/src/main/java/io/fabric8/jenkins/openshiftsync/OpenShiftUtils.java#L448-L462   If the root url from jenkins is set, per that jenkins.model.Jenkins code, we'll get the value from the xml file first.  It will use that before trying to discern from the service.   You are free to open an RFE (not bug) to make such behavior configurable.   thanks

            gmontero Gabe Montero
            bakito Marc Brugger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: