hudson.plugins.dry.util
Class HealthAwarePublisher

java.lang.Object
  extended by hudson.tasks.BuildStepCompatibilityLayer
      extended by hudson.tasks.Publisher
          extended by hudson.plugins.dry.util.HealthAwarePublisher
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.tasks.Publisher>, HealthDescriptor, hudson.tasks.BuildStep, java.io.Serializable
Direct Known Subclasses:
DryPublisher

public abstract class HealthAwarePublisher
extends hudson.tasks.Publisher
implements HealthDescriptor

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 interface hudson.tasks.BuildStep
hudson.tasks.BuildStep.PublisherList
 
Field Summary
 
Fields inherited from interface hudson.tasks.BuildStep
BUILDERS, PUBLISHERS
 
Constructor Summary
HealthAwarePublisher(java.lang.String threshold, java.lang.String healthy, java.lang.String unHealthy, java.lang.String height, java.lang.String thresholdLimit, java.lang.String defaultEncoding, java.lang.String pluginName)
          Creates a new instance of HealthAwarePublisher.
 
Method Summary
protected  boolean canContinue(hudson.model.Result result)
          Returns whether the publisher can continue processing.
 java.lang.String getDefaultEncoding()
          Returns the defined default encoding.
 java.lang.String getHealthy()
          Returns the healthy threshold, i.e.
 int getHealthyAnnotations()
          Returns the healthy threshold for annotations, i.e.
 java.lang.String getHeight()
          Returns the height of the trend graph.
 int getMinimumAnnotations()
          Returns the threshold to be reached if a build should be considered as unstable.
 Priority getMinimumPriority()
          Returns the minimum priority that should be considered when computing build health and stability.
 java.lang.String getThreshold()
          Returns the annotation threshold to be reached if a build should be considered as unstable.
 java.lang.String getThresholdLimit()
          Returns the threshold limit.
 int getTrendHeight()
          Returns the height of the trend graph.
 java.lang.String getUnHealthy()
          Returns the unhealthy threshold, i.e.
 int getUnHealthyAnnotations()
          Returns the unhealthy threshold of annotations, i.e.
protected  boolean isAntBuild(hudson.model.AbstractBuild<?,?> build)
          Returns whether the current build uses ant.
 boolean isHealthyReportEnabled()
          Determines whether a health report should be created.
protected  boolean isMavenBuild(hudson.model.AbstractBuild<?,?> build)
          Returns whether the current build uses maven.
 boolean isThresholdEnabled()
          Determines whether a threshold has been defined.
protected  void log(java.io.PrintStream logger, java.lang.String message)
          Logs the specified message.
 boolean perform(hudson.model.AbstractBuild<?,?> build, hudson.Launcher launcher, hudson.model.BuildListener listener)
          
protected abstract  ParserResult perform(hudson.model.AbstractBuild<?,?> build, java.io.PrintStream logger)
          Performs the publishing of the results of this plug-in.
protected  java.lang.Object readResolve()
          Initializes new fields that are not serialized yet.
 
Methods inherited from class hudson.tasks.Publisher
getProjectAction, needsToRunAfterFinalized, prebuild
 
Methods inherited from class hudson.tasks.BuildStepCompatibilityLayer
getProjectAction, 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.tasks.BuildStep
getProjectAction, prebuild
 
Methods inherited from interface hudson.model.Describable
getDescriptor
 

Constructor Detail

HealthAwarePublisher

public HealthAwarePublisher(java.lang.String threshold,
                            java.lang.String healthy,
                            java.lang.String unHealthy,
                            java.lang.String height,
                            java.lang.String thresholdLimit,
                            java.lang.String defaultEncoding,
                            java.lang.String pluginName)
Creates a new instance of HealthAwarePublisher.

Parameters:
threshold - Tasks threshold to be reached if a build should be considered as unstable.
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
height - the height of the trend graph
thresholdLimit - determines which warning priorities should be considered when evaluating the build stability and health
pluginName - the name of the plug-in
defaultEncoding - the default encoding to be used when reading and parsing files
Method Detail

readResolve

protected java.lang.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 java.lang.InterruptedException,
                             java.io.IOException

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

canContinue

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

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

perform

protected abstract ParserResult perform(hudson.model.AbstractBuild<?,?> build,
                                        java.io.PrintStream logger)
                                 throws java.lang.InterruptedException,
                                        java.io.IOException
Performs the publishing of the results of this plug-in.

Parameters:
build - the build
logger - the logger to report the progress to
Returns:
the java project containing the found annotations
Throws:
java.lang.InterruptedException - If the build is interrupted by the user (in an attempt to abort the build.) Normally the BuildStep implementations may simply forward the exception it got from its lower-level functions.
java.io.IOException - If the implementation wants to abort the processing when an IOException happens, it can simply propagate the exception to the caller. This will cause the build to fail, with the default error message. Implementations are encouraged to catch IOException on its own to provide a better error message, if it can do so, so that users have better understanding on why it failed.

log

protected void log(java.io.PrintStream logger,
                   java.lang.String message)
Logs the specified message.

Parameters:
logger - the logger
message - the message

isThresholdEnabled

public boolean isThresholdEnabled()
Determines whether a threshold has been defined.

Specified by:
isThresholdEnabled in interface HealthDescriptor
Returns:
true if a threshold has been defined

getThreshold

public java.lang.String getThreshold()
Returns the annotation threshold to be reached if a build should be considered as unstable.

Returns:
the annotation threshold to be reached if a build should be considered as unstable.

getMinimumAnnotations

public int getMinimumAnnotations()
Returns the threshold to be reached if a build should be considered as unstable.

Specified by:
getMinimumAnnotations in interface HealthDescriptor
Returns:
the threshold to be reached if a build should be considered as unstable

isHealthyReportEnabled

public boolean isHealthyReportEnabled()
Determines whether a health report should be created.

Specified by:
isHealthyReportEnabled in interface HealthDescriptor
Returns:
true if a health report should be created

getHealthy

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

Returns:
the 100% healthiness

getHealthyAnnotations

public int getHealthyAnnotations()
Returns the healthy threshold for annotations, i.e. when health is reported as 100%.

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

getUnHealthy

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

Returns:
the 0% unhealthiness

getUnHealthyAnnotations

public int getUnHealthyAnnotations()
Returns the unhealthy threshold of annotations, i.e. when health is reported as 0%.

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

getHeight

public java.lang.String getHeight()
Returns the height of the trend graph.

Returns:
the height of the trend graph

getTrendHeight

public int getTrendHeight()
Returns the height of the trend graph.

Returns:
the height of the trend graph

getDefaultEncoding

public java.lang.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 and stability. 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 java.lang.String getThresholdLimit()
Returns the threshold limit.

Returns:
the threshold limit


Copyright © 2009. All Rights Reserved.