Skip to content
Permalink
Browse files

Merge pull request #26 from tom-saunders/master

[JENKINS-13458] Added option to use the previous build as reference.
  • Loading branch information
uhafner committed Nov 19, 2014
2 parents e001040 + 4b277be commit b8712ca11282696b1e8d51eac8a45880a59dff72
@@ -29,6 +29,12 @@
* @since 1.48
*/
private final boolean useStableBuildAsReference;
/**
* Determines whether to always use the previous build as the reference build.
*
* @since 1.66
*/
private final boolean usePreviousBuildAsReference;

/**
* Creates a new instance of {@link AnnotationsAggregator}.
@@ -43,16 +49,23 @@
* 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
* @since 1.66
*/
public AnnotationsAggregator(final MatrixBuild build, final Launcher launcher, final BuildListener listener,
final HealthDescriptor healthDescriptor, final String defaultEncoding, final boolean useStableBuildAsReference) {
final HealthDescriptor healthDescriptor, final String defaultEncoding,
final boolean usePreviousBuildAsReference,
final boolean useStableBuildAsReference) {
super(build, launcher, listener);

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

@@ -96,6 +109,18 @@ public boolean useOnlyStableBuildsAsReference() {
return useStableBuildAsReference;
}

/**
* Determines whether to always use the previous build as the reference
* build.
*
* @return <code>true</code> if the previous build should always be used as
* the reference build.
* @since 1.66
*/
public boolean usePreviousBuildAsReference() {
return usePreviousBuildAsReference;
}

/**
* Returns the annotations of the specified run.
*
@@ -121,6 +146,31 @@ public boolean useOnlyStableBuildsAsReference() {
@SuppressWarnings("hiding")
protected abstract Action createAction(HealthDescriptor healthDescriptor, String defaultEncoding, ParserResult aggregatedResult);

/**
* Creates a new instance of {@link AnnotationsAggregator}.
*
* @param build
* the matrix build
* @param launcher
* the launcher
* @param listener
* the build listener
* @param healthDescriptor
* 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
* @deprecated use {@link #AnnotationsAggregator(MatrixBuild, Launcher,
* BuildListener, HealthDescriptor, String, boolean, boolean)}
*/
@Deprecated
public AnnotationsAggregator(final MatrixBuild build, final Launcher launcher, final BuildListener listener,
final HealthDescriptor healthDescriptor, final String defaultEncoding, final boolean useStableBuildAsReference)
{
this(build, launcher, listener, healthDescriptor, defaultEncoding, false, useStableBuildAsReference);
}
/**
* Creates a new instance of {@link AnnotationsAggregator}.
*
@@ -28,6 +28,10 @@
private final Class<? extends ResultAction<? extends BuildResult>> type;
/** Determines whether only stable builds should be used as reference builds or not. */
private final boolean useStableBuildAsReference;
/** Determines if the previous build should always be used as the reference build.
* @since 1.66
*/
private final boolean usePreviousBuildAsReference;

/**
* Creates a new instance of {@link BuildHistory}.
@@ -36,18 +40,43 @@
* the build to start the history from
* @param type
* type of the action that contains the build results
* @param usePreviousBuildAsReference
* determines whether the previous build should always be used
* as the reference build
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @since 1.47
* @since 1.66
*/
public BuildHistory(final AbstractBuild<?, ?> baseline, final Class<? extends ResultAction<? extends BuildResult>> type,
public BuildHistory(final AbstractBuild<?, ?> baseline,
final Class<? extends ResultAction<? extends BuildResult>> type,
final boolean usePreviousBuildAsReference,
final boolean useStableBuildAsReference) {
this.baseline = baseline;
this.type = type;
this.usePreviousBuildAsReference = usePreviousBuildAsReference;
this.useStableBuildAsReference = useStableBuildAsReference;
}

/**
* Creates a new instance of {@link BuildHistory}.
*
* @param baseline
* the build to start the history from
* @param type
* type of the action that contains the build results
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
* @since 1.47
* @deprecated
*/
@Deprecated
public BuildHistory(final AbstractBuild<?, ?> baseline, final Class<? extends ResultAction<? extends BuildResult>> type,
final boolean useStableBuildAsReference) {
this(baseline, type, false, useStableBuildAsReference);
}

/**
* Determines whether only stable builds should be used as reference builds
* or not.
@@ -95,6 +124,9 @@ public AnnotationContainer getReferenceAnnotations() {
* such build exists
*/
private ResultAction<? extends BuildResult> getReferenceAction() {
if (usePreviousBuildAsReference) {
return getPreviousAction();
}
ResultAction<? extends BuildResult> action = getAction(true, useStableBuildAsReference);
if (action == null) {
return getPreviousAction(); // fallback, use action of previous build regardless of result
@@ -29,6 +29,7 @@
public abstract class HealthAwarePublisher extends HealthAwareRecorder {
private static final long serialVersionUID = -4225952809165635796L;


/**
* Creates a new instance of {@link HealthAwarePublisher}.
*
@@ -81,6 +82,9 @@
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determine if the previous build should always be used as the
* reference build, no matter its overall result.
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
@@ -96,7 +100,7 @@
* workspace for matching files.
* @param pluginName
* the name of the plug-in
* @since 1.48
* @since 1.66
*/
@SuppressWarnings("PMD")
public HealthAwarePublisher(final String healthy, final String unHealthy,
@@ -108,15 +112,20 @@ public HealthAwarePublisher(final String healthy, final String unHealthy,
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 canRunOnFailed,
final boolean usePreviousBuildAsReference,
final boolean useStableBuildAsReference,
final boolean shouldDetectModules, final boolean canComputeNew,
final boolean canResolveRelativePaths, final String pluginName) {
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, canResolveRelativePaths, pluginName);
super(healthy, unHealthy, thresholdLimit, defaultEncoding,
useDeltaValues, unstableTotalAll, unstableTotalHigh,
unstableTotalNormal, unstableTotalLow, unstableNewAll,
unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal,
failedTotalLow, failedNewAll, failedNewHigh, failedNewNormal,
failedNewLow, canRunOnFailed, usePreviousBuildAsReference,
useStableBuildAsReference, shouldDetectModules, canComputeNew,
canResolveRelativePaths, pluginName);
}

/**
@@ -255,6 +264,35 @@ public HealthAwarePublisher(final String threshold, final String newThreshold,
thresholdLimit, defaultEncoding, useDeltaValues, canRunOnFailed, pluginName);
}

/** Backwards compatibility.
* @deprecated
*/
@Deprecated
public HealthAwarePublisher(final String healthy, final String unHealthy,
final String thresholdLimit, final String defaultEncoding,
final boolean useDeltaValues, final String unstableTotalAll,
final String unstableTotalHigh, final String unstableTotalNormal,
final String unstableTotalLow, 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 boolean canResolveRelativePaths, final String pluginName) {
this(healthy, unHealthy, thresholdLimit, defaultEncoding,
useDeltaValues, unstableTotalAll, unstableTotalHigh,
unstableTotalNormal, unstableTotalLow, unstableNewAll,
unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal,
failedTotalLow, failedNewAll, failedNewHigh, failedNewNormal,
failedNewLow, canRunOnFailed, false, useStableBuildAsReference,
shouldDetectModules, canComputeNew, canResolveRelativePaths,
pluginName);
}

@SuppressWarnings({"PMD","javadoc"})
@Deprecated
public HealthAwarePublisher(final String healthy, final String unHealthy,
@@ -63,6 +63,11 @@
* @since 1.6
*/
private final boolean canRunOnFailed;
/** Determines whether the previous build should always be used as the
* reference build.
* @since 1.66
*/
private final boolean usePreviousBuildAsReference;
/**
* Determines whether only stable builds should be used as reference builds
* or not.
@@ -160,6 +165,9 @@
* annotation threshold
* @param canRunOnFailed
* determines whether the plug-in can run for failed builds, too
* @param usePreviousBuildAsReference
* determine if the previous build should always be used as the
* reference build, no matter its overall result.
* @param useStableBuildAsReference
* determines whether only stable builds should be used as
* reference builds or not
@@ -187,7 +195,8 @@ public HealthAwareRecorder(final String healthy, final String unHealthy,
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 canRunOnFailed, final boolean usePreviousBuildAsReference,
final boolean useStableBuildAsReference,
final boolean shouldDetectModules, final boolean canComputeNew,
final boolean canResolveRelativePaths, final String pluginName) {
super();
@@ -218,6 +227,7 @@ public HealthAwareRecorder(final String healthy, final String unHealthy,
thresholds.failedNewLow = failedNewLow;

this.canRunOnFailed = canRunOnFailed;
this.usePreviousBuildAsReference = usePreviousBuildAsReference;
this.useStableBuildAsReference = useStableBuildAsReference;
this.shouldDetectModules = shouldDetectModules;
this.pluginName = "[" + pluginName + "] ";
@@ -259,6 +269,10 @@ protected boolean isThresholdEnabled() {
return new NullHealthDescriptor(this).isThresholdEnabled();
}

public boolean getUsePreviousBuildAsReference() {
return usePreviousBuildAsReference;
}

/**
* Determines whether only stable builds should be used as reference builds
* or not.
@@ -659,6 +673,36 @@ public BuildStepMonitor getRequiredMonitorService() {
@Deprecated
private transient String height;

/** Backwards compatibility.
* @deprecated
*/
@Deprecated
@SuppressWarnings("PMD")
public HealthAwareRecorder(final String healthy, final String unHealthy,
final String thresholdLimit, final String defaultEncoding,
final boolean useDeltaValues, final String unstableTotalAll,
final String unstableTotalHigh, final String unstableTotalNormal,
final String unstableTotalLow, 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 boolean canResolveRelativePaths, final String pluginName) {
this(healthy, unHealthy, thresholdLimit, defaultEncoding,
useDeltaValues, unstableTotalAll, unstableTotalHigh,
unstableTotalNormal, unstableTotalLow, unstableNewAll,
unstableNewHigh, unstableNewNormal, unstableNewLow,
failedTotalAll, failedTotalHigh, failedTotalNormal,
failedTotalLow, failedNewAll, failedNewHigh, failedNewNormal,
failedNewLow, canRunOnFailed, false, useStableBuildAsReference,
shouldDetectModules, canComputeNew, canResolveRelativePaths,
pluginName);
}

/** Backward compatibility. @deprecated */
@SuppressWarnings({"PMD","javadoc"})
@Deprecated
@@ -680,6 +724,7 @@ public HealthAwareRecorder(final String threshold, final String newThreshold,
this.defaultEncoding = defaultEncoding;
this.useDeltaValues = useDeltaValues;
this.canRunOnFailed = canRunOnFailed;
this.usePreviousBuildAsReference = false;
useStableBuildAsReference = false;
dontComputeNew = false;
shouldDetectModules = false;

0 comments on commit b8712ca

Please sign in to comment.