Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-39950] Use getUrl rather than getShortUrl.
Browse files Browse the repository at this point in the history
getShortUrl does not work with jobs in folders, we rather need to use
getUrl. Since getUrl also has the container url as prefix, this part
needs to be stripped of.
  • Loading branch information
uhafner committed May 26, 2017
1 parent 125845a commit 79da226
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions analysis-collector.iml
Expand Up @@ -65,6 +65,7 @@
<orderEntry type="library" name="Maven: org.jvnet.hudson.plugins:tasks:4.46" level="project" />
<orderEntry type="library" name="Maven: org.jvnet.hudson.plugins:warnings:4.49" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.2" level="project" />
<orderEntry type="library" name="Maven: org.jvnet.hudson.plugins:android-lint:2.4" level="project" />
<orderEntry type="library" name="Maven: org.jenkins-ci.plugins:matrix-project:1.2.1" level="project" />
<orderEntry type="library" name="Maven: org.jenkins-ci.main:maven-plugin:2.9" level="project" />
<orderEntry type="library" name="Maven: org.jenkins-ci.plugins:javadoc:1.0" level="project" />
Expand Down
Expand Up @@ -281,7 +281,7 @@ private String getWarnings(final Job<?, ?> job, final AnalysisHandler handler) {
}

private String getJobPrefix(final Job<?, ?> job) {
return hideJobPrefix ? StringUtils.EMPTY : job.getShortUrl();
return hideJobPrefix ? StringUtils.EMPTY : job.getUrl();
}

/**
Expand Down
Expand Up @@ -2,6 +2,7 @@

import java.util.Collection;

import org.apache.commons.lang.StringUtils;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;
Expand Down Expand Up @@ -207,6 +208,11 @@ public String getTotal(final Job<?, ?> job) {
return warningsAggregator.getTotal(job);
}

private String filterUrl(final String link) {
String prefix = getDashboard().getUrl();
return link.replaceFirst(prefix, StringUtils.EMPTY);
}

/**
* Returns the number of Checkstyle warnings for the specified job.
*
Expand All @@ -215,7 +221,7 @@ public String getTotal(final Job<?, ?> job) {
* @return the number of Checkstyle warnings
*/
public String getCheckStyle(final Job<?, ?> job) {
return warningsAggregator.getCheckStyle(job);
return filterUrl(warningsAggregator.getCheckStyle(job));
}

/**
Expand All @@ -226,7 +232,7 @@ public String getCheckStyle(final Job<?, ?> job) {
* @return the number of duplicate code warnings
*/
public String getDry(final Job<?, ?> job) {
return warningsAggregator.getDry(job);
return filterUrl(warningsAggregator.getDry(job));
}

/**
Expand All @@ -237,7 +243,7 @@ public String getDry(final Job<?, ?> job) {
* @return the number of FindBugs warnings
*/
public String getFindBugs(final Job<?, ?> job) {
return warningsAggregator.getFindBugs(job);
return filterUrl(warningsAggregator.getFindBugs(job));
}

/**
Expand All @@ -248,7 +254,7 @@ public String getFindBugs(final Job<?, ?> job) {
* @return the number of PMD warnings
*/
public String getPmd(final Job<?, ?> job) {
return warningsAggregator.getPmd(job);
return filterUrl(warningsAggregator.getPmd(job));
}

/**
Expand All @@ -259,7 +265,7 @@ public String getPmd(final Job<?, ?> job) {
* @return the number of open tasks
*/
public String getTasks(final Job<?, ?> job) {
return warningsAggregator.getTasks(job);
return filterUrl(warningsAggregator.getTasks(job));
}

/**
Expand All @@ -270,7 +276,7 @@ public String getTasks(final Job<?, ?> job) {
* @return the number of compiler warnings
*/
public String getCompilerWarnings(final Job<?, ?> job) {
return warningsAggregator.getCompilerWarnings(job);
return filterUrl(warningsAggregator.getCompilerWarnings(job));
}

/**
Expand All @@ -281,7 +287,7 @@ public String getCompilerWarnings(final Job<?, ?> job) {
* @return the number of Android lint warnings
*/
public String getAndroidLint(final Job<?, ?> job) {
return warningsAggregator.getAndroidLint(job);
return filterUrl(warningsAggregator.getAndroidLint(job));
}

/**
Expand Down

0 comments on commit 79da226

Please sign in to comment.