Package io.jenkins.plugins.util
Class BuildAction<T>
java.lang.Object
io.jenkins.plugins.util.BuildAction<T>
- Type Parameters:
T
- type of the results
- All Implemented Interfaces:
Action
,ModelObject
,Serializable
,RunAction2
,SimpleBuildStep.LastBuildAction
public abstract class BuildAction<T>
extends Object
implements SimpleBuildStep.LastBuildAction, RunAction2, Serializable
Controls the life cycle of the results in a build. This action persists the results of a build and displays a summary
on the build page. The actual visualization of the results is defined in the matching
summary.jelly
file.
This action also provides access to the detail views: these are rendered using a new view instance.- Author:
- Ullrich Hafner
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
BuildAction
(Run<?, ?> owner, T result) Creates a new instance ofBuildAction
.BuildAction
(Run<?, ?> owner, T result, boolean canSerialize) Creates a new instance ofBuildAction
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract JobAction
<? extends BuildAction<T>> protected abstract AbstractXmlStream
<T> Creates the XML stream to read the results.static <T extends BuildAction<?>>
Optional<T> getBuildActionFromHistoryStartingFrom
(Run<?, ?> baseline, Class<T> buildActionClass) Returns aBuildAction
of the specified baseline build.protected abstract String
Run
<?, ?> getOwner()
Collection
<? extends Action> Returns the repository statistics.void
onAttached
(Run<?, ?> r) void
protected Object
Called after de-serialization to improve the memory usage.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface hudson.model.Action
getDisplayName, getIconFileName, getUrlName
-
Constructor Details
-
BuildAction
Creates a new instance ofBuildAction
.- Parameters:
owner
- the associated build that created the resultresult
- the result to persist with this action
-
BuildAction
Creates a new instance ofBuildAction
.- Parameters:
owner
- the associated build that created the resultresult
- the result to persist with this actioncanSerialize
- determines whether the result should be persisted in the build folder
-
-
Method Details
-
createXmlStream
Creates the XML stream to read the results. This method is invoked by the constructor in thisBuildAction
so this instance is not yet fully initialized when this factory method is called. So just return the stream instance without accessing any fields.- Returns:
- the XML stream
-
getOwner
-
onAttached
- Specified by:
onAttached
in interfaceRunAction2
-
onLoad
- Specified by:
onLoad
in interfaceRunAction2
-
readResolve
Called after de-serialization to improve the memory usage.- Returns:
- this
-
getProjectActions
- Specified by:
getProjectActions
in interfaceSimpleBuildStep.LastBuildAction
-
createProjectAction
-
getResult
Returns the repository statistics. Since the object requires some amount of memory, it is stored in aWeakReference
. So if the current instance has been destroyed by the garbage collector then a new instance will be automatically created by reading the persisted XML data from Jenkins build folder.- Returns:
- the statistics
-
getBuildResultBaseName
-
getBuildActionFromHistoryStartingFrom
public static <T extends BuildAction<?>> Optional<T> getBuildActionFromHistoryStartingFrom(@CheckForNull Run<?, ?> baseline, Class<T> buildActionClass) Returns aBuildAction
of the specified baseline build. If there is no such action for the baseline then the previous build is inspected, and so on. If no previous build contains aBuildAction
then an empty result is returned.- Type Parameters:
T
- type of the results- Parameters:
baseline
- the baseline to start the search withbuildActionClass
- the type of the action to find- Returns:
- the next available
BuildAction
, or an empty result if there is no such action
-