hudson.plugins.analysis.core
Class HealthAwareRecorder

java.lang.Object
  extended by hudson.tasks.BuildStepCompatibilityLayer
      extended by hudson.tasks.Publisher
          extended by hudson.tasks.Recorder
              extended by hudson.plugins.analysis.core.HealthAwareRecorder
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.matrix.MatrixAggregatable, hudson.model.Describable<hudson.tasks.Publisher>, HealthDescriptor, hudson.tasks.BuildStep, Serializable
Direct Known Subclasses:
HealthAwarePublisher

public abstract class HealthAwareRecorder
extends hudson.tasks.Recorder
implements HealthDescriptor, hudson.matrix.MatrixAggregatable

A base class for publishers with the following two characteristics:

Author:
Ulli Hafner
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class hudson.tasks.Publisher
hudson.tasks.Publisher.DescriptorExtensionListImpl
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Nested classes/interfaces inherited from interface hudson.tasks.BuildStep
hudson.tasks.BuildStep.PublisherList
 
Field Summary
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
HealthAwareRecorder(String healthy, String unHealthy, String thresholdLimit, String defaultEncoding, boolean useDeltaValues, String unstableTotalAll, String unstableTotalHigh, String unstableTotalNormal, String unstableTotalLow, String unstableNewAll, String unstableNewHigh, String unstableNewNormal, String unstableNewLow, String failedTotalAll, String failedTotalHigh, String failedTotalNormal, String failedTotalLow, String failedNewAll, String failedNewHigh, String failedNewNormal, String failedNewLow, boolean canRunOnFailed, boolean shouldDetectModules, boolean canComputeNew, boolean canResolveRelativePaths, String pluginName)
          Creates a new instance of HealthAwareRecorder.
HealthAwareRecorder(String threshold, String newThreshold, String failureThreshold, String newFailureThreshold, String healthy, String unHealthy, String thresholdLimit, String defaultEncoding, boolean useDeltaValues, boolean canRunOnFailed, String pluginName)
          Deprecated. 
 
Method Summary
 boolean canComputeNew()
          Returns whether new warnings should be computed (with respect to baseline).
protected  boolean canContinue(hudson.model.Result result)
          Returns whether this publisher can continue processing.
 boolean canResolveRelativePaths()
          Returns whether relative paths in warnings should be resolved using a time expensive operation that scans the whole workspace for matching files.
protected  void copyFilesWithAnnotationsToBuildFolder(File rootDir, hudson.remoting.VirtualChannel channel, Collection<FileAnnotation> annotations)
          Copies all files with annotations from the workspace to the build folder.
 boolean getCanComputeNew()
          Returns whether new warnings should be computed (with respect to baseline).
 boolean getCanResolveRelativePaths()
          Returns whether relative paths in warnings should be resolved using a time expensive operation that scans the whole workspace for matching files.
 boolean getCanRunOnFailed()
          Returns whether this plug-in can run for failed builds, too.
 String getDefaultEncoding()
          Returns the defined default encoding.
 PluginDescriptor getDescriptor()
           
 String getHealthy()
          Returns the healthy threshold, i.e.
 Priority getMinimumPriority()
          Returns the minimum priority that should be considered when computing build health.
 hudson.tasks.BuildStepMonitor getRequiredMonitorService()
          
 boolean getShouldDetectModules()
          Returns whether module names should be derived from Maven POM or Ant build files.
 String getThresholdLimit()
          Returns the threshold limit.
 Thresholds getThresholds()
          Returns the threshold of all annotations to be reached if a build should be considered as unstable or failed, resp.
 String getUnHealthy()
          Returns the unhealthy threshold, i.e.
 boolean getUseDeltaValues()
          Returns whether absolute annotations delta or the actual annotations set difference should be used to evaluate the build stability.
protected  boolean isAntBuild(hudson.model.AbstractBuild<?,?> build)
          Returns whether the current build uses ant.
protected  boolean isMavenBuild(hudson.model.AbstractBuild<?,?> build)
          Returns whether the current build uses maven.
protected  boolean isThresholdEnabled()
          Returns whether there is a health threshold enabled.
 boolean perform(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, hudson.model.BuildListener listener)
          
protected abstract  boolean perform(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, PluginLogger logger)
          Callback method that is invoked after the build where this recorder can collect the results.
protected  Object readResolve()
          Initializes new fields that are not serialized yet.
 boolean shouldDetectModules()
          Returns whether module names should be derived from Maven POM or Ant build files.
 
Methods inherited from class hudson.tasks.Publisher
all, getProjectAction, needsToRun, needsToRunAfterFinalized, prebuild
 
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, getProjectActions, perform, prebuild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hudson.matrix.MatrixAggregatable
createAggregator
 
Methods inherited from interface hudson.tasks.BuildStep
getProjectAction, getProjectActions, prebuild
 

Constructor Detail

HealthAwareRecorder

public HealthAwareRecorder(String healthy,
                           String unHealthy,
                           String thresholdLimit,
                           String defaultEncoding,
                           boolean useDeltaValues,
                           String unstableTotalAll,
                           String unstableTotalHigh,
                           String unstableTotalNormal,
                           String unstableTotalLow,
                           String unstableNewAll,
                           String unstableNewHigh,
                           String unstableNewNormal,
                           String unstableNewLow,
                           String failedTotalAll,
                           String failedTotalHigh,
                           String failedTotalNormal,
                           String failedTotalLow,
                           String failedNewAll,
                           String failedNewHigh,
                           String failedNewNormal,
                           String failedNewLow,
                           boolean canRunOnFailed,
                           boolean shouldDetectModules,
                           boolean canComputeNew,
                           boolean canResolveRelativePaths,
                           String pluginName)
Creates a new instance of HealthAwareRecorder.

Parameters:
healthy - Report health as 100% when the number of open tasks is less than this value
unHealthy - Report health as 0% when the number of open tasks is greater than this value
thresholdLimit - determines which warning priorities should be considered when evaluating the build stability and health
defaultEncoding - the default encoding to be used when reading and parsing files
useDeltaValues - determines whether the absolute annotations delta or the actual annotations set difference should be used to evaluate the build stability
unstableTotalAll - annotation threshold
unstableTotalHigh - annotation threshold
unstableTotalNormal - annotation threshold
unstableTotalLow - annotation threshold
unstableNewAll - annotation threshold
unstableNewHigh - annotation threshold
unstableNewNormal - annotation threshold
unstableNewLow - annotation threshold
failedTotalAll - annotation threshold
failedTotalHigh - annotation threshold
failedTotalNormal - annotation threshold
failedTotalLow - annotation threshold
failedNewAll - annotation threshold
failedNewHigh - annotation threshold
failedNewNormal - annotation threshold
failedNewLow - annotation threshold
canRunOnFailed - determines whether the plug-in can run for failed builds, too
shouldDetectModules - determines whether module names should be derived from Maven POM or Ant build files
canComputeNew - determines whether new warnings should be computed (with respect to baseline)
canResolveRelativePaths - determines whether relative paths in warnings should be resolved using a time expensive operation that scans the whole workspace for matching files.
pluginName - the name of the plug-in

HealthAwareRecorder

@Deprecated
public HealthAwareRecorder(String threshold,
                                      String newThreshold,
                                      String failureThreshold,
                                      String newFailureThreshold,
                                      String healthy,
                                      String unHealthy,
                                      String thresholdLimit,
                                      String defaultEncoding,
                                      boolean useDeltaValues,
                                      boolean canRunOnFailed,
                                      String pluginName)
Deprecated. 

Method Detail

getCanResolveRelativePaths

public boolean getCanResolveRelativePaths()
Returns whether relative paths in warnings should be resolved using a time expensive operation that scans the whole workspace for matching files.

Returns:
true if relative paths can be resolved, false otherwise

canResolveRelativePaths

public boolean canResolveRelativePaths()
Returns whether relative paths in warnings should be resolved using a time expensive operation that scans the whole workspace for matching files.

Returns:
true if relative paths can be resolved, false otherwise

readResolve

protected Object readResolve()
Initializes new fields that are not serialized yet.

Returns:
the object

perform

public final boolean perform(hudson.model.AbstractBuild<?,?> build,
                             hudson.Launcher launcher,
                             hudson.model.BuildListener listener)
                      throws InterruptedException,
                             IOException

Specified by:
perform in interface hudson.tasks.BuildStep
Overrides:
perform in class hudson.tasks.BuildStepCompatibilityLayer
Throws:
InterruptedException
IOException

perform

protected abstract boolean perform(hudson.model.AbstractBuild<?,?> build,
                                   hudson.Launcher launcher,
                                   PluginLogger logger)
                            throws InterruptedException,
                                   IOException
Callback method that is invoked after the build where this recorder can collect the results.

Parameters:
build - current build
launcher - the launcher for this build
logger - the logger
Returns:
true if the build can continue, false otherwise
Throws:
IOException - in case of problems during file copying
InterruptedException - if the user canceled the build

getDescriptor

public PluginDescriptor getDescriptor()
Specified by:
getDescriptor in interface hudson.model.Describable<hudson.tasks.Publisher>
Overrides:
getDescriptor in class hudson.tasks.Recorder

copyFilesWithAnnotationsToBuildFolder

protected void copyFilesWithAnnotationsToBuildFolder(File rootDir,
                                                     hudson.remoting.VirtualChannel channel,
                                                     Collection<FileAnnotation> annotations)
                                              throws IOException,
                                                     FileNotFoundException,
                                                     InterruptedException
Copies all files with annotations from the workspace to the build folder.

Parameters:
rootDir - directory to store the copied files in
channel - channel to get the files from
annotations - annotations determining the actual files to copy
Throws:
IOException - if the files could not be written
FileNotFoundException - if the files could not be written
InterruptedException - if the user cancels the processing

getCanComputeNew

public boolean getCanComputeNew()
Returns whether new warnings should be computed (with respect to baseline).

Returns:
true if new warnings should be computed (with respect to baseline), false otherwise

canComputeNew

public boolean canComputeNew()
Returns whether new warnings should be computed (with respect to baseline).

Returns:
true if new warnings should be computed (with respect to baseline), false otherwise

getCanRunOnFailed

public boolean getCanRunOnFailed()
Returns whether this plug-in can run for failed builds, too.

Returns:
true if this plug-in can run for failed builds, false otherwise

getShouldDetectModules

public boolean getShouldDetectModules()
Returns whether module names should be derived from Maven POM or Ant build files.

Returns:
the can run on failed

shouldDetectModules

public boolean shouldDetectModules()
Returns whether module names should be derived from Maven POM or Ant build files.

Returns:
the can run on failed

canContinue

protected boolean canContinue(hudson.model.Result result)
Returns whether this publisher can continue processing. This default implementation returns true if the property canRunOnFailed is set or if the build is not aborted or failed.

Parameters:
result - build result
Returns:
true if the build can continue

getThresholds

public Thresholds getThresholds()
Returns the threshold of all annotations to be reached if a build should be considered as unstable or failed, resp.

Specified by:
getThresholds in interface HealthDescriptor
Returns:
the threshold

getUseDeltaValues

public boolean getUseDeltaValues()
Returns whether absolute annotations delta or the actual annotations set difference should be used to evaluate the build stability.

Returns:
true if the annotation count should be used, false if the actual (set) difference should be computed

getHealthy

public String getHealthy()
Returns the healthy threshold, i.e. when health is reported as 100%.

Specified by:
getHealthy in interface HealthDescriptor
Returns:
the 100% healthiness

getUnHealthy

public String getUnHealthy()
Returns the unhealthy threshold, i.e. when health is reported as 0%.

Specified by:
getUnHealthy in interface HealthDescriptor
Returns:
the 0% unhealthiness

getDefaultEncoding

public String getDefaultEncoding()
Returns the defined default encoding.

Returns:
the default encoding

isMavenBuild

protected boolean isMavenBuild(hudson.model.AbstractBuild<?,?> build)
Returns whether the current build uses maven.

Parameters:
build - the current build
Returns:
true if the current build uses maven, false otherwise

isAntBuild

protected boolean isAntBuild(hudson.model.AbstractBuild<?,?> build)
Returns whether the current build uses ant.

Parameters:
build - the current build
Returns:
true if the current build uses ant, false otherwise

getMinimumPriority

public Priority getMinimumPriority()
Returns the minimum priority that should be considered when computing build health. E.g., if Priority.NORMAL is returned, then annotations with priority Priority.LOW are ignored.

Specified by:
getMinimumPriority in interface HealthDescriptor
Returns:
the minimum priority to consider

getThresholdLimit

public String getThresholdLimit()
Returns the threshold limit.

Returns:
the threshold limit

getRequiredMonitorService

public hudson.tasks.BuildStepMonitor getRequiredMonitorService()

Specified by:
getRequiredMonitorService in interface hudson.tasks.BuildStep

isThresholdEnabled

protected boolean isThresholdEnabled()
Returns whether there is a health threshold enabled.

Returns:
true if at least one threshold is enabled, false otherwise


Copyright © 2004-2012 Hudson. All Rights Reserved.