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 95b632e commit 0ae7469b4f68430d7c2d29567fb80ef41819b989
@@ -85,7 +85,7 @@ private void initializeFields(final String defaultEncoding, final String high, f
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenTasksResultAction(build, getHealthDescriptor(), defaultEncoding, high, normal, low,
new TasksResult(build, defaultEncoding, new TasksParserResult(), false, high, normal, low));
new TasksResult(build, defaultEncoding, new TasksParserResult(), false, false, high, normal, low));
}

@Override
@@ -1,19 +1,19 @@
package hudson.plugins.tasks;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;

import hudson.Launcher;
import hudson.matrix.MatrixAggregator;
import hudson.matrix.MatrixRun;
import hudson.matrix.MatrixBuild;
import hudson.matrix.MatrixRun;
import hudson.model.BuildListener;
import hudson.plugins.analysis.core.AnnotationsAggregator;
import hudson.plugins.analysis.core.HealthDescriptor;
import hudson.plugins.analysis.util.model.Priority;
import hudson.plugins.tasks.parser.TasksParserResult;

import java.io.IOException;

import org.apache.commons.lang.StringUtils;

/**
* Aggregates {@link TasksResultAction}s of {@link MatrixRun}s into
* {@link MatrixBuild}.
@@ -32,6 +32,7 @@
private String normalTags = StringUtils.EMPTY;
/** Tag identifiers indicating low priority. */
private String lowTags = StringUtils.EMPTY;
private final boolean usePreviousBuildAsReference;
private final boolean useStableBuildAsReference;

/**
@@ -47,17 +48,21 @@
* 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 TasksAnnotationsAggregator(final MatrixBuild build, final Launcher launcher, final BuildListener listener,
final HealthDescriptor healthDescriptor, final String defaultEncoding,
final boolean useStableBuildAsReference) {
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
super(build, launcher, listener);

this.healthDescriptor = healthDescriptor;
this.defaultEncoding = defaultEncoding;
this.usePreviousBuildAsReference = usePreviousBuildAsReference;
this.useStableBuildAsReference = useStableBuildAsReference;
}

@@ -79,7 +84,8 @@ public boolean endRun(final MatrixRun run) throws InterruptedException, IOExcept

@Override
public boolean endBuild() throws InterruptedException, IOException {
TasksResult result = new TasksResult(build, defaultEncoding, totals, useStableBuildAsReference, highTags, normalTags, lowTags);
TasksResult result = new TasksResult(build, defaultEncoding, totals,
usePreviousBuildAsReference, useStableBuildAsReference, highTags, normalTags, lowTags);

build.addAction(new TasksResultAction(build, healthDescriptor, result));

@@ -35,7 +35,7 @@
@SuppressWarnings("deprecation")
public TasksMavenResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final TasksParserResult result,
final String highTags, final String normalTags, final String lowTags) {
super(build, defaultEncoding, result, false, highTags, normalTags, lowTags, MavenTasksResultAction.class);
super(build, defaultEncoding, result, false, false, highTags, normalTags, lowTags, MavenTasksResultAction.class);
}

@SuppressWarnings("deprecation")
@@ -1,21 +1,21 @@
package hudson.plugins.tasks;

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

import com.google.common.collect.Lists;

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.MavenResultAction;
import hudson.plugins.tasks.parser.TasksParserResult;

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

import com.google.common.collect.Lists;

/**
* A {@link TasksResultAction} for native Maven jobs. This action
* additionally provides result aggregation for sub-modules and for the main
@@ -77,7 +77,7 @@ private void initializeFields(final String high, final String normal, final Stri
@Override
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new TasksMavenResultAction(build, getHealthDescriptor(), getDefaultEncoding(), high, normal, low,
new TasksResult(build, high, new TasksParserResult(), false, high, normal, low));
new TasksResult(build, high, new TasksParserResult(), false, false, high, normal, low));
}

@Override
@@ -93,7 +93,8 @@ public Action getProjectAction(final MavenModuleSet moduleSet) {
@Override
protected TasksResult createResult(final TasksResult existingResult, final TasksResult additionalResult) {
return new TasksReporterResult(getOwner(), additionalResult.getDefaultEncoding(),
aggregate(existingResult, additionalResult), existingResult.useOnlyStableBuildsAsReference(),
aggregate(existingResult, additionalResult),
existingResult.usePreviousBuildAsStable(), existingResult.useOnlyStableBuildsAsReference(),
high, normal, low);
}

@@ -96,6 +96,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
@@ -127,15 +129,16 @@ public TasksPublisher(final String healthy, final String unHealthy, final String
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 canComputeNew,
final String high, final String normal, final String low, final boolean ignoreCase, final boolean asRegexp,
final String pattern, final String excludePattern) {
final boolean canRunOnFailed, final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final boolean shouldDetectModules, final boolean canComputeNew, final String high, final String normal, final String low,
final boolean ignoreCase, final boolean asRegexp, final String pattern, final String excludePattern) {
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, true, "TASKS");
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference,
shouldDetectModules, canComputeNew, true, "TASKS");
this.pattern = pattern;
this.excludePattern = excludePattern;
this.high = high;
@@ -224,8 +227,9 @@ protected BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogge
logger.logLines(project.getLogMessages());
logger.log(String.format("Found %d open tasks.", project.getNumberOfAnnotations()));

TasksResult result = new TasksResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference(), high, normal, low);
build.getActions().add(new TasksResultAction(build, this, result));
TasksResult result = new TasksResult(build, getDefaultEncoding(), project,
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference(), high, normal, low);
build.addAction(new TasksResultAction(build, this, result));

return result;
}
@@ -238,6 +242,7 @@ public TasksDescriptor getDescriptor() {
@Override
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new TasksAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
return new TasksAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(),
usePreviousBuildAsReference(), useOnlyStableBuildsAsReference());
}
}
@@ -111,6 +111,8 @@
* if the identifiers should be treated as regular expression
* @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
@@ -126,15 +128,15 @@ public TasksReporter(final String pattern, final String excludePattern,
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 String high, final String normal, final String low,
final boolean ignoreCase, final boolean asRegexp, final boolean canRunOnFailed,
final boolean useStableBuildAsReference, final boolean canComputeNew) {
final String high, final String normal, final String low, final boolean ignoreCase, final boolean asRegexp,
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, "TASKS");
canRunOnFailed, usePreviousBuildAsReference, useStableBuildAsReference, canComputeNew, "TASKS");
this.pattern = pattern;
this.excludePattern = excludePattern;
this.high = high;
@@ -234,7 +236,7 @@ public TasksParserResult perform(final MavenBuildProxy build, final MavenProject
@edu.umd.cs.findbugs.annotations.SuppressWarnings("BC")
protected TasksResult createResult(final MavenBuild build, final ParserResult project) {
return new TasksReporterResult(build, getDefaultEncoding(), (TasksParserResult)project,
useOnlyStableBuildsAsReference(), high, normal, low);
usePreviousBuildAsStable(), useOnlyStableBuildsAsReference(), high, normal, low);
}

@Override
@@ -22,6 +22,8 @@
* the default encoding to be used when reading and parsing files
* @param result
* the parsed annotations
* @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
@@ -33,8 +35,10 @@
* tag identifiers indicating low priority
*/
public TasksReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final TasksParserResult result,
final boolean useStableBuildAsReference, final String highTags, final String normalTags, final String lowTags) {
super(build, defaultEncoding, result, useStableBuildAsReference, highTags, normalTags, lowTags, TasksMavenResultAction.class);
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final String highTags, final String normalTags, final String lowTags) {
super(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
highTags, normalTags, lowTags, TasksMavenResultAction.class);
}

@Override
@@ -1,19 +1,19 @@
package hudson.plugins.tasks; // NOPMD

import java.util.ArrayList;

import org.apache.commons.lang.StringUtils;

import com.thoughtworks.xstream.XStream;

import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.BuildHistory;
import hudson.plugins.analysis.core.ResultAction;
import hudson.plugins.analysis.core.BuildResult;
import hudson.plugins.analysis.core.ResultAction;
import hudson.plugins.analysis.util.model.Priority;
import hudson.plugins.tasks.parser.Task;
import hudson.plugins.tasks.parser.TasksParserResult;

import java.util.ArrayList;

import org.apache.commons.lang.StringUtils;

import com.thoughtworks.xstream.XStream;

/**
* Represents the results of the task scanner. One instance of this class is persisted for
* each build via an XML file.
@@ -38,6 +38,8 @@
* the default encoding to be used when reading and parsing files
* @param result
* the parsed annotations
* @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
@@ -48,10 +50,11 @@
* @param lowTags
* tag identifiers indicating low priority
*/
public TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final TasksParserResult result, final boolean useStableBuildAsReference,
public TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final TasksParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final String highTags, final String normalTags, final String lowTags) {
this(build, defaultEncoding, result, useStableBuildAsReference, highTags, normalTags, lowTags, TasksResultAction.class);
this(build, defaultEncoding, result, usePreviousBuildAsReference, useStableBuildAsReference,
highTags, normalTags, lowTags, TasksResultAction.class);
}

/**
@@ -63,6 +66,8 @@ public TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding
* the default encoding to be used when reading and parsing files
* @param result
* the parsed annotations
* @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
@@ -76,12 +81,13 @@ public TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding
* the type of the result action
*/
// CHECKSTYLE:OFF
protected TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final TasksParserResult result, final boolean useStableBuildAsReference,
protected TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final TasksParserResult result,
final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference,
final String highTags, final String normalTags, final String lowTags,
final Class<? extends ResultAction<TasksResult>> actionType) {
// CHECKSTYLE:ON
super(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding);
super(build, new BuildHistory(build, actionType, usePreviousBuildAsReference, useStableBuildAsReference),
result, defaultEncoding);

this.highTags = highTags;
this.normalTags = normalTags;

0 comments on commit 0ae7469

Please sign in to comment.
You can’t perform that action at this time.