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

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-15037] Optionally consider only stable builds as reference b…
…uilds
  • Loading branch information
davidparsson committed Sep 14, 2012
1 parent 73c898e commit 6dd2798
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -32,7 +32,7 @@
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-core</artifactId>
<version>1.45</version>
<version>1.47</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/hudson/plugins/checkstyle/CheckStylePublisher.java
Expand Up @@ -87,6 +87,8 @@ public class CheckStylePublisher extends HealthAwarePublisher {
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param shouldDetectModules
* determines whether module names should be derived from Maven POM or Ant build files
* @param canComputeNew
Expand All @@ -104,14 +106,15 @@ public CheckStylePublisher(final String healthy, final String unHealthy, final S
final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow,
final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow,
final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow,
final boolean canRunOnFailed, final boolean shouldDetectModules, final boolean canComputeNew,
final String pattern) {
final boolean canRunOnFailed, final boolean useStableBuildAsReference, final boolean shouldDetectModules,
final boolean canComputeNew, final String pattern) {
super(healthy, unHealthy, thresholdLimit, defaultEncoding, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, shouldDetectModules, canComputeNew, PLUGIN_NAME);
canRunOnFailed, useStableBuildAsReference, shouldDetectModules, canComputeNew,
true, PLUGIN_NAME);
this.pattern = pattern;
}
// CHECKSTYLE:ON
Expand Down Expand Up @@ -140,7 +143,7 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
ParserResult project = build.getWorkspace().act(parser);
logger.logLines(project.getLogMessages());

CheckStyleResult result = new CheckStyleResult(build, getDefaultEncoding(), project);
CheckStyleResult result = new CheckStyleResult(build, getDefaultEncoding(), project, getUseStableBuildAsReference());
build.getActions().add(new CheckStyleResultAction(build, this, result));

return result;
Expand Down
Expand Up @@ -82,6 +82,8 @@ public class CheckStyleReporter extends HealthAwareReporter<CheckStyleResult> {
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param canComputeNew
* determines whether new warnings should be computed (with
* respect to baseline)
Expand All @@ -94,13 +96,13 @@ public CheckStyleReporter(final String healthy, final String unHealthy, final St
final String unstableNewAll, final String unstableNewHigh, final String unstableNewNormal, final String unstableNewLow,
final String failedTotalAll, final String failedTotalHigh, final String failedTotalNormal, final String failedTotalLow,
final String failedNewAll, final String failedNewHigh, final String failedNewNormal, final String failedNewLow,
final boolean canRunOnFailed, final boolean canComputeNew) {
final boolean canRunOnFailed, final boolean useStableBuildAsReference, final boolean canComputeNew) {
super(healthy, unHealthy, thresholdLimit, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, canComputeNew, PLUGIN_NAME);
canRunOnFailed, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
}
// CHECKSTYLE:ON

Expand Down
42 changes: 40 additions & 2 deletions src/main/java/hudson/plugins/checkstyle/CheckStyleResult.java
Expand Up @@ -27,9 +27,46 @@ public class CheckStyleResult extends BuildResult {
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public CheckStyleResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, useStableBuildAsReference, CheckStyleResultAction.class);
}

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

/**
* Creates a new instance of {@link CheckStyleResult}.
*
* @param build
* the current build as owner of this action
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @param useStableBuildAsReference FIXME
* @param actionType
* the type of the result action
*/
protected CheckStyleResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean useStableBuildAsReference, final Class<? extends ResultAction<CheckStyleResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding, true);
}

/**
Expand All @@ -44,9 +81,10 @@ public CheckStyleResult(final AbstractBuild<?, ?> build, final String defaultEnc
* @param actionType
* the type of the result action
*/
@Deprecated
protected CheckStyleResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final Class<? extends ResultAction<CheckStyleResult>> actionType) {
this(build, new BuildHistory(build, actionType), result, defaultEncoding, true);
this(build, new BuildHistory(build, actionType, false), result, defaultEncoding, true);
}

CheckStyleResult(final AbstractBuild<?, ?> build, final BuildHistory history,
Expand Down

0 comments on commit 6dd2798

Please sign in to comment.