Skip to content
Permalink
Browse files

[FIXED JENKINS-13458] Added an option to use previous build as a refe…

…rence.
  • Loading branch information
uhafner committed Jan 5, 2015
1 parent c1074d6 commit 2b0b1b8d1b3da6fdb454b4e3caabce62e22c8a7d
@@ -29,20 +29,25 @@
* health descriptor
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param usePreviousBuildAsReference
* determines whether the previous build should be used as the
* reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
*/
public FindBugsAnnotationsAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener, final HealthDescriptor healthDescriptor, final String defaultEncoding,
final boolean useStableBuildAsReference) {
super(build, launcher, listener, healthDescriptor, defaultEncoding, useStableBuildAsReference);
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
super(build, launcher, listener, healthDescriptor, defaultEncoding,
usePreviousBuildAsReference, useStableBuildAsReference);
}

@Override
protected Action createAction(final HealthDescriptor healthDescriptor, final String defaultEncoding, final ParserResult aggregatedResult) {
return new FindBugsResultAction(build, healthDescriptor,
new FindBugsResult(build, defaultEncoding, aggregatedResult, useOnlyStableBuildsAsReference()));
new FindBugsResult(build, defaultEncoding, aggregatedResult, usePreviousBuildAsReference(),
useOnlyStableBuildsAsReference()));
}

@Override
@@ -28,7 +28,7 @@
@SuppressWarnings("deprecation")
public FindBugsMavenResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result) {
super(build, defaultEncoding, result, false, MavenFindBugsResultAction.class);
super(build, defaultEncoding, result, false, false, MavenFindBugsResultAction.class);
}

@SuppressWarnings("deprecation")
@@ -41,7 +41,7 @@ public FindBugsMavenResultAction(final AbstractBuild<?, ?> owner, final HealthDe
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new FindBugsMavenResultAction(build, getHealthDescriptor(), getDefaultEncoding(),
new FindBugsResult(build, getDefaultEncoding(), new ParserResult(), false));
new FindBugsResult(build, getDefaultEncoding(), new ParserResult(), false, false));
}

@Override
@@ -57,7 +57,9 @@ public Action getProjectAction(final MavenModuleSet moduleSet) {
@Override
protected FindBugsResult createResult(final FindBugsResult existingResult, final FindBugsResult additionalResult) {
return new FindBugsReporterResult(getOwner(), additionalResult.getDefaultEncoding(),
aggregate(existingResult, additionalResult), existingResult.useOnlyStableBuildsAsReference());
aggregate(existingResult, additionalResult),
existingResult.usePreviousBuildAsStable(),
existingResult.useOnlyStableBuildsAsReference());
}
}

@@ -98,6 +98,8 @@
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determines whether to always use the previous build as the reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param shouldDetectModules
@@ -125,14 +127,14 @@ public FindBugsPublisher(final String healthy, final String unHealthy, final Str
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 useStableBuildAsReference, final boolean shouldDetectModules,
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference, final boolean shouldDetectModules,
final String pattern, final boolean isRankActivated, final boolean canComputeNew, final String excludePattern, final String includePattern) {
super(healthy, unHealthy, thresholdLimit, defaultEncoding, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, useStableBuildAsReference, shouldDetectModules, canComputeNew, false, PLUGIN_NAME);
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, shouldDetectModules, canComputeNew, false, PLUGIN_NAME);
this.pattern = pattern;
this.isRankActivated = isRankActivated;
this.excludePattern= excludePattern;
@@ -192,9 +194,10 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
new FindBugsParser(isRankActivated, getExcludePattern(), getIncludePattern()), shouldDetectModules(), isMavenBuild(build));
ParserResult project = build.getWorkspace().act(collector);
logger.logLines(project.getLogMessages());
FindBugsResult result = new FindBugsResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference());
FindBugsResult result = new FindBugsResult(build, getDefaultEncoding(), project,
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());

build.getActions().add(new FindBugsResultAction(build, this, result));
build.addAction(new FindBugsResultAction(build, this, result));

return result;
}
@@ -207,6 +210,7 @@ public FindBugsDescriptor getDescriptor() {
@Override
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new FindBugsAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
return new FindBugsAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(),
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
}
}
@@ -103,6 +103,8 @@
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determines whether to always use the previous build as the reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as reference builds or not
* @param isRankActivated
@@ -124,13 +126,14 @@ public FindBugsReporter(final String healthy, final String unHealthy, final Stri
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 useStableBuildAsReference, final boolean isRankActivated, final boolean canComputeNew, final String excludePattern, final String includePattern) {
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final boolean isRankActivated, final boolean canComputeNew, final String excludePattern, final String includePattern) {
super(healthy, unHealthy, thresholdLimit, useDeltaValues,
unstableTotalAll, unstableTotalHigh, unstableTotalNormal, unstableTotalLow,
unstableNewAll, unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal, failedTotalLow,
failedNewAll, failedNewHigh, failedNewNormal, failedNewLow,
canRunOnFailed, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
this.isRankActivated = isRankActivated;
this.excludePattern = excludePattern;
this.includePattern = includePattern;
@@ -224,7 +227,8 @@ private FilePath getOutputPath(final MojoInfo mojo, final MavenProject pom) {

@Override
protected FindBugsResult createResult(final MavenBuild build, final ParserResult project) {
return new FindBugsReporterResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference());
return new FindBugsReporterResult(build, getDefaultEncoding(), project,
usePreviousBuildAsStable(), useOnlyStableBuildsAsReference());
}

@Override
@@ -22,13 +22,17 @@
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @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 FindBugsReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result, final boolean useStableBuildAsReference) {
super(build, defaultEncoding, result, useStableBuildAsReference, FindBugsMavenResultAction.class);
public FindBugsReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
super(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
FindBugsMavenResultAction.class);
}

@Override
@@ -1,15 +1,15 @@
package hudson.plugins.findbugs;

import com.thoughtworks.xstream.XStream;

import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.core.ResultAction;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.util.model.FileAnnotation;
import hudson.plugins.findbugs.parser.Bug;

import com.thoughtworks.xstream.XStream;

/**
* Represents the results of the FindBugs analysis. One instance of this class is persisted for
* each build via an XML file.
@@ -34,13 +34,17 @@
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @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 FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final ParserResult result, final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, useStableBuildAsReference, FindBugsResultAction.class);
public FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
FindBugsResultAction.class);
}

/**
@@ -52,15 +56,20 @@ public FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncod
* the default encoding to be used when reading and parsing files
* @param result
* the parsed result with all annotations
* @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
* @param actionType
* the type of the result action
*/
protected FindBugsResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean useStableBuildAsReference, final Class<? extends ResultAction<FindBugsResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding, true);
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final Class<? extends ResultAction<FindBugsResult>> actionType) {
this(build, new BuildHistory(build, actionType, usePreviousBuildAsReference, useStableBuildAsReference),
result, defaultEncoding, true);
}

FindBugsResult(final AbstractBuild<?, ?> build, final BuildHistory history,
@@ -1,19 +1,19 @@
package hudson.plugins.findbugs;

import java.util.List;
import java.util.Map;

import hudson.maven.AggregatableAction;
import hudson.maven.MavenAggregatedReport;
import hudson.maven.MavenBuild;
import hudson.maven.MavenModule;
import hudson.maven.MavenModuleSet;
import hudson.maven.MavenModuleSetBuild;
import hudson.model.Action;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.plugins.analysis.core.HealthDescriptor;
import hudson.plugins.analysis.core.ParserResult;

import java.util.List;
import java.util.Map;

/**
* A {@link FindBugsResultAction} for native maven jobs. This action
* additionally provides result aggregation for sub-modules and for the main
@@ -48,7 +48,7 @@ public MavenFindBugsResultAction(final AbstractBuild<?, ?> owner, final HealthDe
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenFindBugsResultAction(build, getHealthDescriptor(), defaultEncoding,
new FindBugsResult(build, defaultEncoding, new ParserResult(), false));
new FindBugsResult(build, defaultEncoding, new ParserResult(), false, false));
}

@Override

0 comments on commit 2b0b1b8

Please sign in to comment.