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

Commit

Permalink
[JENKINS-29959] Workflow compatible. Added new tests (workflow specific)
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Recena authored and recena committed Aug 23, 2015
1 parent 53d5b39 commit ee546a8
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 52 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 1,7 @@
/target/
/work/
.DS_Store
/target
/npm-debug.log
/Plug-Ins

.idea
44 changes: 23 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 4,19 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>1.59</version>
<version>1.63</version>
</parent>

<artifactId>warnings</artifactId>
<packaging>hpi</packaging>
<name>Warnings Plug-in</name>
<version>4.49-SNAPSHOT</version>
<url>http://wiki.jenkins-ci.org/x/G4CGAQ</url>
<description>This plug-in reads the compiler warnings from the
console log file and generates a trend report.
</description>
<description>This plug-in reads the compiler warnings from the console log file and generates a trend report.</description>

<properties>
<workflow-jenkins-plugin.version>1.4</workflow-jenkins-plugin.version>
</properties>

<licenses>
<license>
Expand All @@ -23,41 25,29 @@
</license>
<license>
<name>LGPL</name>
<comments>All icons are made by Carlitus (Carles Carbonell
Bernado) and are under the LGPL.
</comments>
<comments>All icons are made by Carlitus (Carles Carbonell Bernado) and are under the LGPL.</comments>
</license>
<license>
<name>BSD license</name>
<comments>All YUI source code is under the BSD license. Duke, the Java mascot also is under the BSD license.
</comments>
<comments>All YUI source code is under the BSD license. Duke, the Java mascot also is under the BSD license.</comments>
</license>
<license>
<name>Scala License</name>
<url>http://www.scala-lang.org/license.html</url>
<comments>Scala icons are made by converting of http://www.scala-lang.org/resources/img/smooth-spiral.png
</comments>
<comments>Scala icons are made by converting of http://www.scala-lang.org/resources/img/smooth-spiral.png</comments>
</license>
<license>
<name>Creative Commons Attribution 3.0</name>
<url>https://creativecommons.org/licenses/by/3.0</url>
<comments>Go mascot and logo were designed by Renée French and are covered by the Creative Commons Attribution 3.0
license
</comments>
<comments>Go mascot and logo were designed by Renée French and are covered by the Creative Commons Attribution 3.0 license.</comments>
</license>
</licenses>

<dependencies>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-core</artifactId>
<version>1.73-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-test</artifactId>
<version>1.12</version>
<scope>test</scope>
<version>1.73-beta-SNAPSHOT</version><!-- TODO: change to 1.73 before release -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand All @@ -75,6 65,18 @@
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-test</artifactId>
<version>1.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>${workflow-jenkins-plugin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<scm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@

import hudson.model.AbstractBuild;

import hudson.model.Run;
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.ResultAction;
Expand Down Expand Up @@ -31,9 32,30 @@ public class AggregatedWarningsResult extends BuildResult {
* the parsed result with all annotations
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
*
* @deprecated see {@link #AggregatedWarningsResult(Run, BuildHistory, ParserResult, String)}
*/
@Deprecated
public AggregatedWarningsResult(final AbstractBuild<?, ?> build, final BuildHistory history, final ParserResult result,
final String defaultEncoding) {
this((Run<?, ?>) build, history, result, defaultEncoding);

}

/**
* Creates a new instance of {@link AggregatedWarningsResult}.
*
* @param build
* the current build as owner of this action
* @param history
* build history
* @param result
* the parsed result with all annotations
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
*/
public AggregatedWarningsResult(final Run<?, ?> build, final BuildHistory history, final ParserResult result,
final String defaultEncoding) {
super(build, history, result, defaultEncoding);

serializeAnnotations(result.getAnnotations());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 2,7 @@

import hudson.model.AbstractBuild;

import hudson.model.Run;
import hudson.plugins.analysis.core.NullHealthDescriptor;
import hudson.plugins.analysis.core.AbstractResultAction;
import hudson.plugins.analysis.core.PluginDescriptor;
Expand All @@ -23,8 24,23 @@ public class AggregatedWarningsResultAction extends AbstractResultAction<Aggrega
* the associated build of this action
* @param result
* the result in this build
*
* @deprecated see {@link #AggregatedWarningsResultAction(Run, AggregatedWarningsResult)}
*/
@Deprecated
public AggregatedWarningsResultAction(final AbstractBuild<?, ?> owner, final AggregatedWarningsResult result) {
this((Run<? ,?>) owner, result);
}

/**
* Creates a new instance of <code>WarningsResultAction</code>.
*
* @param owner
* the associated build of this action
* @param result
* the result in this build
*/
public AggregatedWarningsResultAction(final Run<?, ?> owner, final AggregatedWarningsResult result) {
super(owner, NULL_HEALTH_DESCRIPTOR, result);
}

Expand Down
41 changes: 41 additions & 0 deletions src/main/java/hudson/plugins/warnings/WarningsBuildHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 4,7 @@
import java.util.List;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.plugins.analysis.core.BuildHistory;

/**
Expand All @@ -27,15 28,38 @@ public class WarningsBuildHistory extends BuildHistory {
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*
* @deprecated use {@link #WarningsBuildHistory(Run, String, boolean, boolean)}
*/
@Deprecated
public WarningsBuildHistory(final AbstractBuild<?, ?> lastFinishedBuild, @CheckForNull final String group,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
this((Run<?, ?>) lastFinishedBuild, group, usePreviousBuildAsReference, useStableBuildAsReference);
}

/**
* Creates a new instance of {@link WarningsBuildHistory}.
*
* @param lastFinishedBuild
* the last finished build
* @param group
* the parser group
* @param usePreviousBuildAsReference
* determines whether to use the previous build as the reference
* build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public WarningsBuildHistory(final Run<?, ?> lastFinishedBuild, @CheckForNull final String group,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
super(lastFinishedBuild, WarningsResultAction.class, usePreviousBuildAsReference, useStableBuildAsReference);

this.group = group;
}

@Override
@Deprecated
public WarningsResultAction getResultAction(final AbstractBuild<?, ?> build) {
List<WarningsResultAction> actions = build.getActions(WarningsResultAction.class);
if (group != null) {
Expand All @@ -50,5 74,22 @@ public WarningsResultAction getResultAction(final AbstractBuild<?, ?> build) {
}
return null;
}

@Override
public WarningsResultAction getResultAction(final Run<?, ?> build) {
List<WarningsResultAction> actions = build.getActions(WarningsResultAction.class);
if (group != null) {
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;
}

}

Loading

0 comments on commit ee546a8

Please sign in to comment.