Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[JENKINS-15037] Added flag to consider stable reference builds only.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Sep 24, 2012
1 parent b4bf044 commit e9fbcb2
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 320 deletions.
Expand Up @@ -280,7 +280,7 @@ protected BuildHistory createBuildHistory() {
return new NullBuildHistory();
}
else {
return new BuildHistory(lastFinishedBuild, resultActionType);
return new BuildHistory(lastFinishedBuild, resultActionType, false);
}
}

Expand Down
Expand Up @@ -22,7 +22,13 @@ public abstract class AnnotationsAggregator extends MatrixAggregator {
private final ParserResult totals = new ParserResult();
private final HealthDescriptor healthDescriptor;
private final String defaultEncoding;

/**
* Determines whether only stable builds should be used as reference builds
* or not.
*
* @since 1.48
*/
private final boolean useStableBuildAsReference;
/**
* Creates a new instance of {@link AnnotationsAggregator}.
*
Expand All @@ -36,13 +42,17 @@ public abstract class AnnotationsAggregator 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 AnnotationsAggregator(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
Expand Down Expand Up @@ -75,6 +85,16 @@ protected boolean hasResult(final MatrixRun run) {
return false;
}

/**
* Determines whether only stable builds should be used as reference builds
* or not.
*
* @return <code>true</code> if only stable builds should be used
*/
public boolean useOnlyStableBuildsAsReference() {
return useStableBuildAsReference;
}

/**
* Returns the annotations of the specified run.
*
Expand All @@ -99,5 +119,26 @@ protected boolean hasResult(final MatrixRun run) {
*/
@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
* @deprecated use {@link #AnnotationsAggregator(MatrixBuild, Launcher, BuildListener, HealthDescriptor, String, boolean)}
*/
@Deprecated
public AnnotationsAggregator(final MatrixBuild build, final Launcher launcher, final BuildListener listener,
final HealthDescriptor healthDescriptor, final String defaultEncoding) {
this(build, launcher, listener, healthDescriptor, defaultEncoding, false);
}
}

29 changes: 20 additions & 9 deletions src/main/java/hudson/plugins/analysis/core/BuildHistory.java
Expand Up @@ -26,7 +26,7 @@ public class BuildHistory {
private final AbstractBuild<?, ?> baseline;
/** Type of the action that contains the build results. */
private final Class<? extends ResultAction<? extends BuildResult>> type;
/** Determines whether only stable builds should be used as reference builds or not */
/** Determines whether only stable builds should be used as reference builds or not. */
private final boolean useStableBuildAsReference;

/**
Expand All @@ -49,16 +49,13 @@ public BuildHistory(final AbstractBuild<?, ?> baseline, final Class<? extends Re
}

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

/**
Expand Down Expand Up @@ -285,5 +282,19 @@ public Collection<FileAnnotation> getFixedWarnings(final Set<FileAnnotation> ann
public AbstractHealthDescriptor getHealthDescriptor() {
return getBaseline().getHealthDescriptor();
}

/**
* 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
* @deprecated use {@link #BuildHistory(AbstractBuild, Class, boolean)}
*/
@Deprecated
public BuildHistory(final AbstractBuild<?, ?> baseline, final Class<? extends ResultAction<? extends BuildResult>> type) {
this(baseline, type, false);
}
}

12 changes: 11 additions & 1 deletion src/main/java/hudson/plugins/analysis/core/BuildResult.java
Expand Up @@ -223,7 +223,17 @@ protected BuildResult(final AbstractBuild<?, ?> build, final BuildHistory histor
* @return the history
*/
protected BuildHistory createHistory(final AbstractBuild<?, ?> build) {
return new BuildHistory(build, getResultActionType());
return new BuildHistory(build, getResultActionType(), false);
}

/**
* Determines whether only stable builds should be used as reference builds
* or not.
*
* @return <code>true</code> if only stable builds should be used
*/
public boolean useOnlyStableBuildsAsReference() {
return history.useOnlyStableBuildsAsReference();
}

/**
Expand Down

0 comments on commit e9fbcb2

Please sign in to comment.