Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Merge pull request #2 from tom-saunders/master

[JENKINS-13458] Added option to use the previous build always as reference.
  • Loading branch information
uhafner committed Nov 19, 2014
2 parents 0724a86 + 68d6cfd commit 9494c7483bef499a10f1585ddfde004d0718ed07
@@ -49,7 +49,7 @@ public MavenPmdResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenPmdResultAction(build, getHealthDescriptor(), defaultEncoding,
new PmdResult(build, defaultEncoding, new ParserResult(), false));
new PmdResult(build, defaultEncoding, new ParserResult(), false, false));
}

@Override
@@ -32,17 +32,22 @@
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @param usePreviousBuildAsReference
* determines whether the previous build should be used as the
* reference build
*/
public PmdAnnotationsAggregator(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 useStableBuildAsReference,
final boolean usePreviousBuildAsReference) {
super(build, launcher, listener, healthDescriptor, defaultEncoding,
useStableBuildAsReference, usePreviousBuildAsReference);
}

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

@Override
@@ -42,7 +42,7 @@ public PmdMavenResultAction(final AbstractBuild<?, ?> owner, final HealthDescrip
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new PmdMavenResultAction(build, getHealthDescriptor(), getDefaultEncoding(),
new PmdResult(build, getDefaultEncoding(), new ParserResult(), false));
new PmdResult(build, getDefaultEncoding(), new ParserResult(), false, false));
}

@Override
@@ -86,6 +86,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 canComputeNew
@@ -105,14 +107,18 @@ public PmdPublisher(final String healthy, final String unHealthy, final String t
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 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, useStableBuildAsReference, shouldDetectModules, canComputeNew, false, PLUGIN_NAME);
canRunOnFailed,
usePreviousBuildAsReference,
useStableBuildAsReference, shouldDetectModules, canComputeNew, false, PLUGIN_NAME);
this.pattern = pattern;
}
// CHECKSTYLE:ON
@@ -139,7 +145,7 @@ public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger l
ParserResult project = build.getWorkspace().act(pmdCollector);
logger.logLines(project.getLogMessages());

PmdResult result = new PmdResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference());
PmdResult result = new PmdResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference(), getUsePreviousBuildAsReference());
build.getActions().add(new PmdResultAction(build, this, result));

return result;
@@ -153,6 +159,8 @@ public PmdDescriptor getDescriptor() {
@Override
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new PmdAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
return new PmdAnnotationsAggregator(build, launcher, listener, this,
getDefaultEncoding(), useOnlyStableBuildsAsReference(),
getUsePreviousBuildAsReference());
}
}
@@ -80,6 +80,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 canComputeNew
@@ -94,13 +96,14 @@ public PmdReporter(final String healthy, final String unHealthy, final String th
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 canComputeNew) {
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference,
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, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, PLUGIN_NAME);
}
// CHECKSTYLE:ON

@@ -27,33 +27,37 @@
* 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 PmdResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
public PmdResult(final AbstractBuild<?, ?> build,
final String defaultEncoding,
final ParserResult result,
final boolean usePreviousBuildAsReference,
final boolean useStableBuildAsReference) {
this(build, defaultEncoding, result, useStableBuildAsReference, PmdResultAction.class);
this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference, PmdResultAction.class);
}

/**
* Creates a new instance of {@link PmdResult}.
*
* @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
* determines whether only stable builds should be used as
* reference builds or not
* @param actionType
* the type of the result action
* @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 usePreviousBuildAsReference the value of usePreviousBuildAsReference
* @param useStableBuildAsReference determines whether only stable builds should be used as
reference builds or not
* @param actionType the type of the result action
*/
protected PmdResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final ParserResult result,
final boolean useStableBuildAsReference, final Class<? extends ResultAction<PmdResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding, true);
protected PmdResult(final AbstractBuild<?, ?> build,
final String defaultEncoding, final ParserResult result,
boolean usePreviousBuildAsReference,
final boolean useStableBuildAsReference,
final Class<? extends ResultAction<PmdResult>> actionType) {
this(build, new BuildHistory(build, actionType, useStableBuildAsReference, usePreviousBuildAsReference), result, defaultEncoding, true);
}

PmdResult(final AbstractBuild<?, ?> build, final BuildHistory history,

0 comments on commit 9494c74

Please sign in to comment.