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() + 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.
Released in 1.4.0