Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[JENKINS-15037]: Upgrade to new API in order to compute warnings only
for stable builds (if option is checked).
  • Loading branch information
uhafner committed Sep 28, 2012
1 parent 7563749 commit 7fc0ef593e20049dd7f627834945f22ce8d5f6ff
@@ -60,28 +60,6 @@ public MavenTasksResultAction(final AbstractBuild<?, ?> owner, final HealthDescr
}
// CHECKSTYLE:ON

/**
* Creates a new instance of {@link MavenTasksResultAction}.
*
* @param owner
* the associated build of this action
* @param healthDescriptor
* health descriptor to use
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @param high
* tag identifiers indicating high priority
* @param normal
* tag identifiers indicating normal priority
* @param low
* tag identifiers indicating low priority
*/
public MavenTasksResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor healthDescriptor, final String defaultEncoding,
final String high, final String normal, final String low) {
super(owner, healthDescriptor);
initializeFields(defaultEncoding, high, normal, low);
}

/**
* Initializes the fields of this action.
*
@@ -106,7 +84,8 @@ private void initializeFields(final String defaultEncoding, final String high, f

/** {@inheritDoc} */
public MavenAggregatedReport createAggregatedAction(final MavenModuleSetBuild build, final Map<MavenModule, List<MavenBuild>> moduleBuilds) {
return new MavenTasksResultAction(build, getHealthDescriptor(), defaultEncoding, high, normal, low);
return new MavenTasksResultAction(build, getHealthDescriptor(), defaultEncoding, high, normal, low,
new TasksResult(build, defaultEncoding, new TasksParserResult(), false, high, normal, low));
}

/** {@inheritDoc} */
@@ -32,6 +32,7 @@ public class TasksAnnotationsAggregator extends MatrixAggregator {
private String normalTags = StringUtils.EMPTY;
/** Tag identifiers indicating low priority. */
private String lowTags = StringUtils.EMPTY;
private final boolean useStableBuildAsReference;

/**
* Creates a new instance of {@link AnnotationsAggregator}.
@@ -46,13 +47,18 @@ public class TasksAnnotationsAggregator extends MatrixAggregator {
* health descriptor
* @param defaultEncoding
* the default encoding to be used when reading and parsing files
* @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 HealthDescriptor healthDescriptor, final String defaultEncoding,
final boolean useStableBuildAsReference) {
super(build, launcher, listener);

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

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

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

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

@@ -35,7 +35,7 @@ public class TasksMavenResult extends TasksResult {
@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, highTags, normalTags, lowTags, MavenTasksResultAction.class);
super(build, defaultEncoding, result, false, highTags, normalTags, lowTags, MavenTasksResultAction.class);
}

@SuppressWarnings("deprecation")
@@ -77,7 +77,7 @@ private void initializeFields(final String high, final String normal, final Stri
/** {@inheritDoc} */
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(), high, normal, low));
new TasksResult(build, high, new TasksParserResult(), false, high, normal, low));
}

/** {@inheritDoc} */
@@ -93,7 +93,8 @@ public Class<? extends MavenResultAction<TasksResult>> getIndividualActionType()
@Override
protected TasksResult createResult(final TasksResult existingResult, final TasksResult additionalResult) {
return new TasksReporterResult(getOwner(), additionalResult.getDefaultEncoding(),
aggregate(existingResult, additionalResult), high, normal, low);
aggregate(existingResult, additionalResult), existingResult.useOnlyStableBuildsAsReference(),
high, normal, low);
}

@Override
@@ -96,6 +96,8 @@ public class TasksPublisher 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 canComputeNew
* determines whether new warnings should be computed (with
* respect to baseline)
@@ -121,15 +123,15 @@ 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 shouldDetectModules, final boolean canComputeNew,
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 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, shouldDetectModules, canComputeNew, "TASKS");
canRunOnFailed, useStableBuildAsReference, shouldDetectModules, canComputeNew, true, "TASKS");
this.pattern = pattern;
this.excludePattern = excludePattern;
this.high = high;
@@ -208,7 +210,7 @@ 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, high, normal, low);
TasksResult result = new TasksResult(build, getDefaultEncoding(), project, useOnlyStableBuildsAsReference(), high, normal, low);
build.getActions().add(new TasksResultAction(build, this, result));

return result;
@@ -222,6 +224,6 @@ public TasksDescriptor getDescriptor() {
/** {@inheritDoc} */
public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher,
final BuildListener listener) {
return new TasksAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding());
return new TasksAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), useOnlyStableBuildsAsReference());
}
}
@@ -107,6 +107,8 @@ public class TasksReporter extends HealthAwareReporter<TasksResult> {
* if case should be ignored during matching
* @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)
@@ -121,13 +123,13 @@ public TasksReporter(final String pattern, final String excludePattern,
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 canRunOnFailed, final boolean canComputeNew) {
final boolean ignoreCase, 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, "TASKS");
canRunOnFailed, useStableBuildAsReference, canComputeNew, "TASKS");
this.pattern = pattern;
this.excludePattern = excludePattern;
this.high = high;
@@ -216,7 +218,8 @@ excludePattern, getDefaultEncoding(), high, normal, low, ignoreCase, pom.getName
@Override
@edu.umd.cs.findbugs.annotations.SuppressWarnings("BC")
protected TasksResult createResult(final MavenBuild build, final ParserResult project) {
return new TasksReporterResult(build, getDefaultEncoding(), (TasksParserResult)project, high, normal, low);
return new TasksReporterResult(build, getDefaultEncoding(), (TasksParserResult)project,
useOnlyStableBuildsAsReference(), high, normal, low);
}

@Override
@@ -22,6 +22,9 @@ public class TasksReporterResult extends TasksResult {
* the default encoding to be used when reading and parsing files
* @param result
* the parsed annotations
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @param highTags
* tag identifiers indicating high priority
* @param normalTags
@@ -30,8 +33,8 @@ public class TasksReporterResult extends TasksResult {
* tag identifiers indicating low priority
*/
public TasksReporterResult(final AbstractBuild<?, ?> build, final String defaultEncoding, final TasksParserResult result,
final String highTags, final String normalTags, final String lowTags) {
super(build, defaultEncoding, result, highTags, normalTags, lowTags, TasksMavenResultAction.class);
final boolean useStableBuildAsReference, final String highTags, final String normalTags, final String lowTags) {
super(build, defaultEncoding, result, useStableBuildAsReference, highTags, normalTags, lowTags, TasksMavenResultAction.class);
}

@Override
@@ -38,6 +38,9 @@ public class TasksResult extends BuildResult {
* the default encoding to be used when reading and parsing files
* @param result
* the parsed annotations
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @param highTags
* tag identifiers indicating high priority
* @param normalTags
@@ -46,8 +49,9 @@ public class TasksResult extends BuildResult {
* tag identifiers indicating low priority
*/
public TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final TasksParserResult result, final String highTags, final String normalTags, final String lowTags) {
this(build, defaultEncoding, result, highTags, normalTags, lowTags, TasksResultAction.class);
final TasksParserResult result, final boolean useStableBuildAsReference,
final String highTags, final String normalTags, final String lowTags) {
this(build, defaultEncoding, result, useStableBuildAsReference, highTags, normalTags, lowTags, TasksResultAction.class);
}

/**
@@ -59,6 +63,9 @@ 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 useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @param highTags
* tag identifiers indicating high priority
* @param normalTags
@@ -68,10 +75,13 @@ public TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding
* @param actionType
* the type of the result action
*/
// CHECKSTYLE:OFF
protected TasksResult(final AbstractBuild<?, ?> build, final String defaultEncoding,
final TasksParserResult result, final String highTags, final String normalTags, final String lowTags,
final TasksParserResult result, final boolean useStableBuildAsReference,
final String highTags, final String normalTags, final String lowTags,
final Class<? extends ResultAction<TasksResult>> actionType) {
super(build, new BuildHistory(build, actionType), result, defaultEncoding);
// CHECKSTYLE:ON
super(build, new BuildHistory(build, actionType, useStableBuildAsReference), result, defaultEncoding);

this.highTags = highTags;
this.normalTags = normalTags;
@@ -1,9 +1,9 @@
package hudson.plugins.tasks;

import hudson.model.AbstractBuild;
import hudson.plugins.analysis.core.AbstractResultAction;
import hudson.plugins.analysis.core.HealthDescriptor;
import hudson.plugins.analysis.core.PluginDescriptor;
import hudson.plugins.analysis.core.AbstractResultAction;

/**
* Controls the live cycle of the task scanner results. This action persists the
@@ -31,18 +31,6 @@ public TasksResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor
super(owner, new TasksHealthDescriptor(healthDescriptor), result);
}

/**
* Creates a new instance of <code>TasksResultAction</code>.
*
* @param owner
* the associated build of this action
* @param healthDescriptor
* health descriptor to use
*/
public TasksResultAction(final AbstractBuild<?, ?> owner, final HealthDescriptor healthDescriptor) {
super(owner, new TasksHealthDescriptor(healthDescriptor));
}

/** {@inheritDoc} */
public String getDisplayName() {
return Messages.Tasks_ProjectAction_Name();
@@ -1,16 +1,15 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"
xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson"
xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:result="/result" xmlns:tasks="/tasks">
<l:layout norefresh="true">
<st:include it="${it.owner}" page="sidepanel.jelly" />
<l:main-panel>
<h1>${it.header}</h1>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:result="/result" xmlns:tasks="/tasks">
<l:layout norefresh="true">
<st:include it="${it.owner}" page="sidepanel.jelly" />
<l:main-panel>
<h1>${it.header}</h1>

<h2>${%Fixed Tasks}</h2>
<h2>${%Fixed Tasks}</h2>

<tasks:fixed />
<tasks:fixed />

</l:main-panel>
</l:layout>
</l:main-panel>
</l:layout>
</j:jelly>

0 comments on commit 7fc0ef5

Please sign in to comment.