This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-10319] When computing the build history correctly select the
results that use the same parser. If there is no such result then try to use the action of the 3.x parsers.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/main/java/hudson/plugins/warnings/WarningsBuildHistory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package hudson.plugins.warnings; | ||
|
||
import hudson.model.AbstractBuild; | ||
import hudson.plugins.analysis.core.BuildHistory; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* A build history for warnings results. Picks the right action using the parser group. | ||
* | ||
* @author Ulli Hafner | ||
*/ | ||
public class WarningsBuildHistory extends BuildHistory { | ||
private final String group; | ||
|
||
/** | ||
* Creates a new instance of {@link WarningsBuildHistory}. | ||
* | ||
* @param lastFinishedBuild | ||
* the last finished build | ||
* @param group | ||
* the parser group | ||
*/ | ||
public WarningsBuildHistory(final AbstractBuild<?, ?> lastFinishedBuild, final String group) { | ||
super(lastFinishedBuild, WarningsResultAction.class); | ||
|
||
this.group = group; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public WarningsResultAction getResultAction(final AbstractBuild<?, ?> build) { | ||
List<WarningsResultAction> actions = build.getActions(WarningsResultAction.class); | ||
for (WarningsResultAction action : actions) { | ||
if (group.equals(action.getParser())) { | ||
return action; | ||
} | ||
} | ||
if (!actions.isEmpty() && actions.get(0).getParser() == null) { // fallback 3.x | ||
return actions.get(0); | ||
} | ||
return null; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters