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

Analyzer Icons aren't displayed if Jenkins isn't installed at root context.

      The paths to icons appears to assume that Jenkins has been installed at the root webapp context. If this isn't the case, the images are broken.

      For example, this is one such URL:

      http://[host]/plugin/build-failure-analyzer/images/16x16/information.png

      But because my jenkins url is http://[host]/jenkins, the above produces a 404.

          [JENKINS-15948] Analyzer Icons aren't displayed if Jenkins isn't installed at root context.

          Released in 1.4.0

          Tomas Westling added a comment - Released in 1.4.0

          Jenkins installed as war in tomcat. Image URL - http://myhost:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png is broken, double "jenkins" in path.

          Evgeny Kryukov added a comment - Jenkins installed as war in tomcat. Image URL - http://myhost:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png is broken, double "jenkins" in path.

          Jenkins installed as war in tomcat. Image URL - http://myhost:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png is broken, double "jenkins" in path.

          Evgeny Kryukov added a comment - Jenkins installed as war in tomcat. Image URL - http://myhost:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png is broken, double "jenkins" in path.

          The duplicate 'jenkins' in the URL was introduced in the plugin update from version 1.4.0 to 1.4.1. Our Jenkins location URL is set to 'http://host:8080/jenkins/'.

          http://host:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/48x48/information.png
          http://host:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/24x24/newinformation.png

          Christian Apel added a comment - The duplicate 'jenkins' in the URL was introduced in the plugin update from version 1.4.0 to 1.4.1. Our Jenkins location URL is set to 'http://host:8080/jenkins/'. http://host:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/48x48/information.png http://host:8080/jenkins/jenkins/plugin/build-failure-analyzer/images/24x24/newinformation.png

          I confirm that this issue still exists. My Jenkins is installed at "http://jenkins.mycorp.com/jenkins" and the plugin generates URLs with an extra "/jenkins" in the URL like http://jenkins.mycorp.com/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png.

          I had a look to the plugin source and found that the issue was located in method PluginImpl.getFullImageUrl(String, String).

          Here's the initial method code.

              public static String getFullImageUrl(String size, String name) {
                  String url = Mailer.descriptor().getUrl();
                  if (url != null) {
                      String contextPath = "";
                      StaplerRequest currentRequest = Stapler.getCurrentRequest();
                      if (currentRequest != null) {
                          contextPath = currentRequest.getContextPath();
                      }
                      if (contextPath.startsWith("/")) {
                          contextPath = contextPath.substring(1);
                      }
                      return Hudson.getInstance().getRootUrl() + contextPath + getImageUrl(size, name);
                  }
                  return Hudson.getInstance().getRootUrlFromRequest() + getStaticImagesBase()
                          + "/" + size + "/" + name;
              }
          

          When I change the method into the following, the problem is fixed.

              public static String getFullImageUrl(String size, String name) {
                  String url = Mailer.descriptor().getUrl();
                  if (url != null) {
                      String contextPath = "";
                      StaplerRequest currentRequest = Stapler.getCurrentRequest();
                      if (currentRequest != null) {
                          contextPath = currentRequest.getContextPath();
                      }
                      if (contextPath.startsWith("/")) {
                          contextPath = contextPath.substring(1);
                      }
          
                      // return Hudson.getInstance().getRootUrl() + contextPath + getImageUrl(size, name);
                      return Hudson.getInstance().getRootUrl() + getImageUrl(size, name);
                  }
                  return Hudson.getInstance().getRootUrlFromRequest() + getStaticImagesBase()
                          + "/" + size + "/" + name;
              }
          

          However since the method doesn't use the contextPath variable any more, it can be simplified into this:

              public static String getFullImageUrl(String size, String name) {
                  return Hudson.getInstance().getRootUrl() + getImageUrl(size, name);
              }
          

          I must be missing something. Why do we need 2 return statements ? Are the use cases that justify to have 2 return statements ?

          Something else that I noticed during my tests with a fresh local Jenkins 1.537. In "Manage Jenkins" > "Configure System", there's a section "Jenkins Location" and a field "Jenkins URL". By default the "Jenkins URL" field is set to "http://localhost:8080/jenkins/".

          With the default value in the "Jenkins URL" field, the missing icon bug doesn't occur.

          When I changed the "Jenkins URL" field to "http://jenkins.mycorp.com/jenkins", the icons are missing.

          It seems that Jenkins recognizes "http://localhost:8080/jenkins/" as the default url and has a given behavior. When this URL is changed, the behavior changes.

          FRANCOIS RITALY added a comment - I confirm that this issue still exists. My Jenkins is installed at "http://jenkins.mycorp.com/jenkins" and the plugin generates URLs with an extra "/jenkins" in the URL like http://jenkins.mycorp.com/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png . I had a look to the plugin source and found that the issue was located in method PluginImpl.getFullImageUrl(String, String). Here's the initial method code. public static String getFullImageUrl( String size, String name) { String url = Mailer.descriptor().getUrl(); if (url != null ) { String contextPath = ""; StaplerRequest currentRequest = Stapler.getCurrentRequest(); if (currentRequest != null ) { contextPath = currentRequest.getContextPath(); } if (contextPath.startsWith( "/" )) { contextPath = contextPath.substring(1); } return Hudson.getInstance().getRootUrl() + contextPath + getImageUrl(size, name); } return Hudson.getInstance().getRootUrlFromRequest() + getStaticImagesBase() + "/" + size + "/" + name; } When I change the method into the following, the problem is fixed. public static String getFullImageUrl( String size, String name) { String url = Mailer.descriptor().getUrl(); if (url != null ) { String contextPath = ""; StaplerRequest currentRequest = Stapler.getCurrentRequest(); if (currentRequest != null ) { contextPath = currentRequest.getContextPath(); } if (contextPath.startsWith( "/" )) { contextPath = contextPath.substring(1); } // return Hudson.getInstance().getRootUrl() + contextPath + getImageUrl(size, name); return Hudson.getInstance().getRootUrl() + getImageUrl(size, name); } return Hudson.getInstance().getRootUrlFromRequest() + getStaticImagesBase() + "/" + size + "/" + name; } However since the method doesn't use the contextPath variable any more, it can be simplified into this: public static String getFullImageUrl( String size, String name) { return Hudson.getInstance().getRootUrl() + getImageUrl(size, name); } I must be missing something. Why do we need 2 return statements ? Are the use cases that justify to have 2 return statements ? Something else that I noticed during my tests with a fresh local Jenkins 1.537. In "Manage Jenkins" > "Configure System", there's a section "Jenkins Location" and a field "Jenkins URL". By default the "Jenkins URL" field is set to "http://localhost:8080/jenkins/". With the default value in the "Jenkins URL" field, the missing icon bug doesn't occur. When I changed the "Jenkins URL" field to "http://jenkins.mycorp.com/jenkins", the icons are missing. It seems that Jenkins recognizes "http://localhost:8080/jenkins/" as the default url and has a given behavior. When this URL is changed, the behavior changes.

          Julio Gonzalez Gil added a comment - - edited

          Julio Gonzalez Gil added a comment - - edited For me it's happening as well with 1.6.0 and Jenkins 1.537 If jenkins is located at http://jenkins.mycorp.com/jenkins , then some URL for images are written as http://jenkins.mycorp.com/jenkins/jenkins/plugin/build-failure-analyzer/images/* I'm having problems with http://jenkins.mycorp.com/jenkins/jenkins/plugin/build-failure-analyzer/images/48x48/information.png and http://jenkins.mycorp.com/jenkins/jenkins/plugin/build-failure-analyzer/images/16x16/information.png If Jenkins is installed at root folder ( http://jenkins.mycorp.com/ ) then the route is http://jenkins.mycorp.com//plugin/build-failure-analyzer/images/48x48/information.png (incorrect) but the image loads as one slash is ignored.

          Is there a particular reason these this change is not progressing? For more information please see https://wiki.jenkins-ci.org/display/JENKINS/Hyperlinks+in+HTML

          Walter Kacynski added a comment - Is there a particular reason these this change is not progressing? For more information please see https://wiki.jenkins-ci.org/display/JENKINS/Hyperlinks+in+HTML

          Can confirm that this still is an issue.

          Andi Scharfstein added a comment - Can confirm that this still is an issue.

          Problem with "jenkins/jenkins" in the URL still exists in 1.10.0

          Slawa Giterman added a comment - Problem with "jenkins/jenkins" in the URL still exists in 1.10.0

          kumy kumy added a comment -

          We also encounter this issue with Jenkins 2.32.2.

          Url contains a double slash as `http://jenkins.mycorp.com//plugin/build-failure-analyzer/images/48x48/information.png` but Jetty it gives us a 404 error.

          We are using Jenkins docker image `jenkins:2.32.2-alpine`

          kumy kumy added a comment - We also encounter this issue with Jenkins 2.32.2. Url contains a double slash as ` http://jenkins.mycorp.com//plugin/build-failure-analyzer/images/48x48/information.png ` but Jetty it gives us a 404 error. We are using Jenkins docker image `jenkins:2.32.2-alpine`

            t_westling Tomas Westling
            prospero238 Keith Collison
            Votes:
            13 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated: