hudson.plugins.analysis.core
Class BuildResult

java.lang.Object
  extended by hudson.plugins.analysis.core.BuildResult
All Implemented Interfaces:
hudson.model.ModelObject, AnnotationProvider, Serializable

@ExportedBean
public abstract class BuildResult
extends Object
implements hudson.model.ModelObject, Serializable, AnnotationProvider

A base class for build results that is capable of storing a reference to the current build. Provides support for persisting the results of the build and loading and saving of annotations (all, new, and fixed) and delta computation.

Author:
Ulli Hafner
See Also:
Serialized Form

Field Summary
protected  String high
          Deprecated. 
protected  String low
          Deprecated. 
protected  String normal
          Deprecated. 
 
Constructor Summary
protected BuildResult(hudson.model.AbstractBuild<?,?> build, BuildHistory history, ParserResult result, String defaultEncoding)
          Creates a new instance of BuildResult.
  BuildResult(hudson.model.AbstractBuild<?,?> build, String defaultEncoding, ParserResult result)
          Deprecated. use BuildResult(AbstractBuild, BuildHistory, ParserResult, String) The new constructor will not save the annotations anymore. you need to save them manually
  BuildResult(hudson.model.AbstractBuild<?,?> build, String defaultEncoding, ParserResult result, BuildHistory history)
          Deprecated. use BuildResult(AbstractBuild, BuildHistory, ParserResult, String) The new constructor will not save the annotations anymore. you need to save them manually
 
Method Summary
 boolean canUseDeltaValues()
          Returns the whether delta values should be used to compute the new warnings.
protected  void configure(com.thoughtworks.xstream.XStream xstream)
          Configures the XStream.
protected static String createDefaultDeltaMessage(String url, int newWarnings, int fixedWarnings)
          Creates a default delta message for the build result.
protected static String createDefaultSummary(String url, int warnings, int modules)
          Creates a default summary message for the build result.
protected  String createDeltaMessage()
          Returns the build summary HTML delta message.
protected  BuildHistory createHistory(hudson.model.AbstractBuild<?,?> build)
          Creates a new history based on the specified build.
protected static String createUrl(String url)
          Creates an HTML URL reference start tag.
 void evaluateStatus(Thresholds thresholds, boolean useDeltaValues, boolean canComputeNew, PluginLogger logger, String url)
          Updates the build status, i.e.
 void evaluateStatus(Thresholds thresholds, boolean useDeltaValues, PluginLogger logger, String url)
          Updates the build status, i.e.
 FileAnnotation getAnnotation(long key)
          Returns the annotation with the specified key.
 FileAnnotation getAnnotation(String key)
          Returns the annotation with the specified key.
 Set<FileAnnotation> getAnnotations()
          Returns the annotations for this object.
 Set<FileAnnotation> getAnnotations(Priority priority)
          Returns the annotations of the specified priority for this object.
 Set<FileAnnotation> getAnnotations(String priority)
          Returns the annotations of the specified priority for this object.
 hudson.model.Api getApi()
          Gets the remote API for this build result.
 AnnotationContainer getContainer()
          Gets the annotation container.
 hudson.XmlFile getDataFile()
          Returns the serialization file.
static long getDays(long ms)
          Returns the number of days for the specified number of milliseconds.
 String getDefaultEncoding()
          Returns the defined default encoding.
 int getDelta()
          Returns the delta.
 String getDetails()
          Returns the detail messages for the summary.jelly file.
 Object getDynamic(String link, org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response)
          Returns the dynamic result of the selection element.
 List<String> getErrors()
          Returns the error messages associated with this build.
 Collection<FileAnnotation> getFixedWarnings()
          Returns the fixed warnings of this build.
 String getHeader()
          Returns the header for the build result page.
 int getHighDelta()
          Returns the high delta.
 long getHighScoreGap()
          Returns the number of msec still to go before a new highscore is reached.
 BuildHistory getHistory()
          Returns the build history.
 int getLowDelta()
          Returns the low delta.
 Collection<String> getModules()
          Returns the modules of this build result.
 Collection<FileAnnotation> getNewWarnings()
          Returns the new warnings of this build.
 int getNormalDelta()
          Returns the normal delta.
 int getNumberOfAnnotations()
          Gets the number of warnings.
 int getNumberOfAnnotations(Priority priority)
          Returns the total number of warnings of the specified priority for this object.
 int getNumberOfAnnotations(String priority)
          Returns the annotations of the specified priority for this object.
 int getNumberOfFixedWarnings()
          Gets the number of fixed warnings.
 int getNumberOfHighPriorityWarnings()
          Returns the number of warnings with high priority.
 int getNumberOfLowPriorityWarnings()
          Returns the number of warnings with low priority.
 int getNumberOfModules()
          Returns the number of modules in this project.
 int getNumberOfNewWarnings()
          Gets the number of new warnings.
 int getNumberOfNormalPriorityWarnings()
          Returns the number of warnings with normal priority.
 int getNumberOfWarnings()
          Gets the number of warnings.
 hudson.model.AbstractBuild<?,?> getOwner()
          Returns the build as owner of this action.
 hudson.model.Result getPluginResult()
          Returns the Result of the plug-in.
 BuildResult getPreviousResult()
          Returns the previous build result.
 Priority[] getPriorities()
          Returns all possible priorities.
 JavaProject getProject()
          Returns the associated project of this result.
 String getReason()
          Returns the reason for the computed value of the build result.
protected abstract  Class<? extends ResultAction<? extends BuildResult>> getResultActionType()
          Returns the actual type of the associated result action.
 String getResultIcon()
          Returns the icon for the build result.
protected abstract  String getSerializationFileName()
          Returns the name of the file to store the serialized annotations.
 long getSuccessfulHighScore()
          Returns the maximum period of successful builds.
 long getSuccessfulHighScoreGap()
          Returns the number of msec still to go before a new highscore is reached.
 int getSuccessfulSinceBuild()
          Returns the build since we are successful.
 long getSuccessfulSinceDate()
          Returns the time since we are successful.
abstract  String getSummary()
          Returns a summary message for the summary.jelly file.
 Thresholds getThresholds()
          Returns the thresholds used to compute the build health.
 int getWarningsDelta()
          Returns the delta between two builds.
 long getZeroWarningsHighScore()
          Returns the maximum period with zero warnings in a build.
 int getZeroWarningsSinceBuild()
          Returns the build since we have zero warnings.
 long getZeroWarningsSinceDate()
          Returns the time since we have zero warnings.
 boolean hasAnnotations()
          Returns whether this objects has annotations.
 boolean hasAnnotations(Priority priority)
          Returns whether this objects has annotations with the specified priority.
 boolean hasAnnotations(String priority)
          Returns whether this objects has annotations with the specified priority.
 boolean hasError()
          Returns whether a module with an error is part of this project.
 boolean hasNoAnnotations()
          Returns whether this objects has no annotations.
 boolean hasNoAnnotations(Priority priority)
          Returns whether this objects has no annotations with the specified priority.
 boolean hasNoAnnotations(String priority)
          Returns whether this objects has no annotations with the specified priority.
 boolean hasPreviousResult()
          Returns whether there is a previous result available.
 boolean isCurrent()
          Returns whether this result belongs to the last build.
 boolean isNewSuccessfulHighScore()
          Returns if the current result reached the old successful highscore.
 boolean isNewZeroWarningsHighScore()
          Returns if the current result reached the old zero warnings highscore.
 boolean isSuccessful()
          Returns whether this build is successful with respect to the HealthDescriptor of this result.
 boolean isSuccessfulTouched()
          Returns whether the successful state has been touched.
protected  Object readResolve()
          Initializes members that were not present in previous versions of the associated plug-in.
protected  void serializeAnnotations(Collection<FileAnnotation> annotations)
          Serializes the annotations of the specified project and writes them to the file specified by method getDataFile().
protected  void setHighWarnings(int highWarnings)
          Sets the number of high warnings to the specified value.
protected  void setLowWarnings(int lowWarnings)
          Sets the number of low warnings to the specified value.
protected  void setNormalWarnings(int normalWarnings)
          Sets the number of normal warnings to the specified value.
 void setResult(hudson.model.Result result)
          Deprecated. use #evaluateStatus(Thresholds, boolean, PluginLogger)
protected  void setWarnings(int warnings)
          Sets the number of warnings to the specified value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hudson.model.ModelObject
getDisplayName
 

Field Detail

low

@Deprecated
protected transient String low
Deprecated. 

normal

@Deprecated
protected transient String normal
Deprecated. 

high

@Deprecated
protected transient String high
Deprecated. 
Constructor Detail

BuildResult

protected BuildResult(hudson.model.AbstractBuild<?,?> build,
                      BuildHistory history,
                      ParserResult result,
                      String defaultEncoding)
Creates a new instance of BuildResult. Note that the warnings are not serialized anymore automatically. You need to call serializeAnnotations(Collection) manually in your constructor to persist them.

Parameters:
build - the current build as owner of this action
history - build history
result - the parsed result with all annotations
defaultEncoding - the default encoding to be used when reading and parsing files
Since:
1.39

BuildResult

@Deprecated
public BuildResult(hudson.model.AbstractBuild<?,?> build,
                              String defaultEncoding,
                              ParserResult result,
                              BuildHistory history)
Deprecated. use BuildResult(AbstractBuild, BuildHistory, ParserResult, String) The new constructor will not save the annotations anymore. you need to save them manually

Creates a new instance of BuildResult.

Parameters:
build - the current build as owner of this action
defaultEncoding - the default encoding to be used when reading and parsing files
result - the parsed result with all annotations
history - the history of build results of the associated plug-in

BuildResult

@Deprecated
public BuildResult(hudson.model.AbstractBuild<?,?> build,
                              String defaultEncoding,
                              ParserResult result)
Deprecated. use BuildResult(AbstractBuild, BuildHistory, ParserResult, String) The new constructor will not save the annotations anymore. you need to save them manually

Creates a new instance of BuildResult.

Parameters:
build - the current build as owner of this action
defaultEncoding - the default encoding to be used when reading and parsing files
result - the parsed result with all annotations
Method Detail

getDays

public static long getDays(long ms)
Returns the number of days for the specified number of milliseconds.

Parameters:
ms - milliseconds
Returns:
the number of days

createHistory

protected BuildHistory createHistory(hudson.model.AbstractBuild<?,?> build)
Creates a new history based on the specified build.

Parameters:
build - the build to start with
Returns:
the history

getHistory

public BuildHistory getHistory()
Returns the build history.

Returns:
the history

hasError

public boolean hasError()
Returns whether a module with an error is part of this project.

Returns:
true if at least one module has an error.

getErrors

public List<String> getErrors()
Returns the error messages associated with this build.

Returns:
the error messages

readResolve

protected Object readResolve()
Initializes members that were not present in previous versions of the associated plug-in.

Returns:
the created object

getModules

public Collection<String> getModules()
Returns the modules of this build result.

Returns:
the modules

getNumberOfModules

public int getNumberOfModules()
Returns the number of modules in this project.

Returns:
the number of modules

getDefaultEncoding

public String getDefaultEncoding()
Returns the defined default encoding.

Returns:
the default encoding

getThresholds

public Thresholds getThresholds()
Returns the thresholds used to compute the build health.

Returns:
the thresholds

canUseDeltaValues

public boolean canUseDeltaValues()
Returns the whether delta values should be used to compute the new warnings.

Returns:
true if the absolute annotations delta should be used, false if the actual annotations set difference should be used to evaluate the build stability.

getDataFile

public final hudson.XmlFile getDataFile()
Returns the serialization file.

Returns:
the serialization file.

configure

protected void configure(com.thoughtworks.xstream.XStream xstream)
Configures the XStream. This default implementation is empty.

Parameters:
xstream - the stream to configure

getSerializationFileName

protected abstract String getSerializationFileName()
Returns the name of the file to store the serialized annotations.

Returns:
the name of the file to store the serialized annotations

isCurrent

public boolean isCurrent()
Returns whether this result belongs to the last build.

Returns:
true if this result belongs to the last build

getOwner

public hudson.model.AbstractBuild<?,?> getOwner()
Returns the build as owner of this action.

Returns:
the owner

hasAnnotations

public boolean hasAnnotations(Priority priority)
Returns whether this objects has annotations with the specified priority.

Specified by:
hasAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
true if this objects has annotations.

hasAnnotations

public boolean hasAnnotations(String priority)
Returns whether this objects has annotations with the specified priority.

Specified by:
hasAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
true if this objects has annotations.

hasAnnotations

public boolean hasAnnotations()
Returns whether this objects has annotations.

Specified by:
hasAnnotations in interface AnnotationProvider
Returns:
true if this objects has annotations.

hasNoAnnotations

public boolean hasNoAnnotations()
Returns whether this objects has no annotations.

Specified by:
hasNoAnnotations in interface AnnotationProvider
Returns:
true if this objects has no annotations.

hasNoAnnotations

public boolean hasNoAnnotations(Priority priority)
Returns whether this objects has no annotations with the specified priority.

Specified by:
hasNoAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
true if this objects has no annotations.

hasNoAnnotations

public boolean hasNoAnnotations(String priority)
Returns whether this objects has no annotations with the specified priority.

Specified by:
hasNoAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
true if this objects has no annotations.

getAnnotations

@Exported(name="warnings")
public Set<FileAnnotation> getAnnotations()
Returns the annotations for this object.

Specified by:
getAnnotations in interface AnnotationProvider
Returns:
annotations for this object

getAnnotation

public FileAnnotation getAnnotation(long key)
Returns the annotation with the specified key.

Specified by:
getAnnotation in interface AnnotationProvider
Parameters:
key - the key of the annotation
Returns:
the annotation with the specified key

getAnnotation

public FileAnnotation getAnnotation(String key)
Returns the annotation with the specified key.

Specified by:
getAnnotation in interface AnnotationProvider
Parameters:
key - the key of the annotation as a long value in string representation
Returns:
the annotation with the specified key

setHighWarnings

protected void setHighWarnings(int highWarnings)
Sets the number of high warnings to the specified value.

Parameters:
highWarnings - the value to set

setNormalWarnings

protected void setNormalWarnings(int normalWarnings)
Sets the number of normal warnings to the specified value.

Parameters:
normalWarnings - the value to set

setLowWarnings

protected void setLowWarnings(int lowWarnings)
Sets the number of low warnings to the specified value.

Parameters:
lowWarnings - the value to set

setWarnings

protected void setWarnings(int warnings)
Sets the number of warnings to the specified value.

Parameters:
warnings - the value to set

getAnnotations

public Set<FileAnnotation> getAnnotations(Priority priority)
Returns the annotations of the specified priority for this object.

Specified by:
getAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
annotations of the specified priority for this object

serializeAnnotations

protected void serializeAnnotations(Collection<FileAnnotation> annotations)
Serializes the annotations of the specified project and writes them to the file specified by method getDataFile().

Parameters:
annotations - the annotations to store

getZeroWarningsSinceBuild

@Exported
public int getZeroWarningsSinceBuild()
Returns the build since we have zero warnings.

Returns:
the build since we have zero warnings

getZeroWarningsSinceDate

@Exported
public long getZeroWarningsSinceDate()
Returns the time since we have zero warnings.

Returns:
the time since we have zero warnings

getZeroWarningsHighScore

@Exported
public long getZeroWarningsHighScore()
Returns the maximum period with zero warnings in a build.

Returns:
the time since we have zero warnings

isNewZeroWarningsHighScore

@Exported
public boolean isNewZeroWarningsHighScore()
Returns if the current result reached the old zero warnings highscore.

Returns:
true, if the current result reached the old zero warnings highscore.

getHighScoreGap

public long getHighScoreGap()
Returns the number of msec still to go before a new highscore is reached.

Returns:
the number of msec still to go before a new highscore is reached.

getSuccessfulSinceBuild

@Exported
public int getSuccessfulSinceBuild()
Returns the build since we are successful.

Returns:
the build since we are successful

getSuccessfulSinceDate

@Exported
public long getSuccessfulSinceDate()
Returns the time since we are successful.

Returns:
the time since we are successful

getSuccessfulHighScore

@Exported
public long getSuccessfulHighScore()
Returns the maximum period of successful builds.

Returns:
the maximum period of successful builds

isNewSuccessfulHighScore

@Exported
public boolean isNewSuccessfulHighScore()
Returns if the current result reached the old successful highscore.

Returns:
true, if the current result reached the old successful highscore.

getSuccessfulHighScoreGap

public long getSuccessfulHighScoreGap()
Returns the number of msec still to go before a new highscore is reached.

Returns:
the number of msec still to go before a new highscore is reached.

getNumberOfWarnings

@Exported
public int getNumberOfWarnings()
Gets the number of warnings.

Returns:
the number of warnings

getNumberOfAnnotations

public int getNumberOfAnnotations()
Gets the number of warnings.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Returns:
the number of warnings

getNumberOfAnnotations

public int getNumberOfAnnotations(Priority priority)
Returns the total number of warnings of the specified priority for this object.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Parameters:
priority - the priority
Returns:
total number of annotations of the specified priority for this object

getNumberOfFixedWarnings

@Exported
public int getNumberOfFixedWarnings()
Gets the number of fixed warnings.

Returns:
the number of fixed warnings

getNumberOfNewWarnings

@Exported
public int getNumberOfNewWarnings()
Gets the number of new warnings.

Returns:
the number of new warnings

getDelta

public int getDelta()
Returns the delta.

Returns:
the delta

getHighDelta

public int getHighDelta()
Returns the high delta.

Returns:
the delta

getNormalDelta

public int getNormalDelta()
Returns the normal delta.

Returns:
the delta

getLowDelta

public int getLowDelta()
Returns the low delta.

Returns:
the delta

getWarningsDelta

@Exported
public int getWarningsDelta()
Returns the delta between two builds.

Returns:
the delta

getNumberOfHighPriorityWarnings

@Exported
public int getNumberOfHighPriorityWarnings()
Returns the number of warnings with high priority.

Returns:
the number of warnings with high priority

getNumberOfNormalPriorityWarnings

@Exported
public int getNumberOfNormalPriorityWarnings()
Returns the number of warnings with normal priority.

Returns:
the number of warnings with normal priority

getNumberOfLowPriorityWarnings

@Exported
public int getNumberOfLowPriorityWarnings()
Returns the number of warnings with low priority.

Returns:
the number of warnings with low priority

getProject

public JavaProject getProject()
Returns the associated project of this result.

Returns:
the associated project of this result.

getNewWarnings

@Exported
public Collection<FileAnnotation> getNewWarnings()
Returns the new warnings of this build.

Returns:
the new warnings of this build

getFixedWarnings

public Collection<FileAnnotation> getFixedWarnings()
Returns the fixed warnings of this build.

Returns:
the fixed warnings of this build.

getResultActionType

protected abstract Class<? extends ResultAction<? extends BuildResult>> getResultActionType()
Returns the actual type of the associated result action.

Returns:
the actual type of the associated result action

getDynamic

public Object getDynamic(String link,
                         org.kohsuke.stapler.StaplerRequest request,
                         org.kohsuke.stapler.StaplerResponse response)
Returns the dynamic result of the selection element.

Parameters:
link - the link to identify the sub page to show
request - Stapler request
response - Stapler response
Returns:
the dynamic result of the analysis (detail page).

getPriorities

public Priority[] getPriorities()
Returns all possible priorities.

Returns:
all priorities

getAnnotations

public Set<FileAnnotation> getAnnotations(String priority)
Returns the annotations of the specified priority for this object.

Specified by:
getAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
annotations of the specified priority for this object

getNumberOfAnnotations

public int getNumberOfAnnotations(String priority)
Returns the annotations of the specified priority for this object.

Specified by:
getNumberOfAnnotations in interface AnnotationProvider
Parameters:
priority - the priority as a string object
Returns:
annotations of the specified priority for this object

getContainer

public AnnotationContainer getContainer()
Gets the annotation container.

Returns:
the container

getApi

public hudson.model.Api getApi()
Gets the remote API for this build result.

Returns:
the remote API

isSuccessful

public boolean isSuccessful()
Returns whether this build is successful with respect to the HealthDescriptor of this result.

Returns:
true if the build is successful, false if the build has been set to Result.UNSTABLE or Result.FAILURE by this result.

evaluateStatus

public void evaluateStatus(Thresholds thresholds,
                           boolean useDeltaValues,
                           PluginLogger logger,
                           String url)
Updates the build status, i.e. sets this plug-in result status field to the corresponding Result. Additionally, the Result of the build that owns this instance of BuildResult will be also changed.

Parameters:
thresholds - the failure thresholds
useDeltaValues - the use delta values when computing the differences
logger - the logger
url - the URL of the results

evaluateStatus

public void evaluateStatus(Thresholds thresholds,
                           boolean useDeltaValues,
                           boolean canComputeNew,
                           PluginLogger logger,
                           String url)
Updates the build status, i.e. sets this plug-in result status field to the corresponding Result. Additionally, the Result of the build that owns this instance of BuildResult will be also changed.

Parameters:
thresholds - the failure thresholds
useDeltaValues - the use delta values when computing the differences
canComputeNew - determines whether new warnings should be computed (with respect to baseline)
logger - the logger
url - the URL of the results

setResult

@Deprecated
public void setResult(hudson.model.Result result)
Deprecated. use #evaluateStatus(Thresholds, boolean, PluginLogger)


getPluginResult

public hudson.model.Result getPluginResult()
Returns the Result of the plug-in.

Returns:
the plugin result

isSuccessfulTouched

public boolean isSuccessfulTouched()
Returns whether the successful state has been touched.

Returns:
true if the successful state has been touched, false otherwise

hasPreviousResult

public boolean hasPreviousResult()
Returns whether there is a previous result available.

Returns:
true if there is a previous result available

getPreviousResult

public BuildResult getPreviousResult()
Returns the previous build result.

Returns:
the previous build result

getReason

public String getReason()
Returns the reason for the computed value of the build result.

Returns:
the reason

createDefaultSummary

protected static String createDefaultSummary(String url,
                                             int warnings,
                                             int modules)
Creates a default summary message for the build result. Typically, you can call this method in getSummary() to create the actual visible user message.

Parameters:
url - the URL to the build results
warnings - number of warnings
modules - number of modules
Returns:
the summary message

createUrl

protected static String createUrl(String url)
Creates an HTML URL reference start tag.

Parameters:
url - the URL
Returns:
the HTML tag

createDefaultDeltaMessage

protected static String createDefaultDeltaMessage(String url,
                                                  int newWarnings,
                                                  int fixedWarnings)
Creates a default delta message for the build result. Typically, you can call this method in createDeltaMessage() to create the actual visible user message.

Parameters:
url - the URL to the build results
newWarnings - number of new warnings
fixedWarnings - number of fixed warnings
Returns:
the summary message

getSummary

public abstract String getSummary()
Returns a summary message for the summary.jelly file.

Returns:
the summary message

getDetails

public String getDetails()
Returns the detail messages for the summary.jelly file.

Returns:
the summary message

getResultIcon

public String getResultIcon()
Returns the icon for the build result.

Returns:
the icon for the build result

getHeader

public String getHeader()
Returns the header for the build result page.

Returns:
the header for the build result page

createDeltaMessage

protected String createDeltaMessage()
Returns the build summary HTML delta message.

Returns:
the build summary HTML message

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2012 Hudson. All Rights Reserved.