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 Details

    • BuildAction

      protected BuildAction(Run<?,?> owner, T result)
      Creates a new instance of BuildAction.
      Parameters:
      owner - the associated build that created the result
      result - the result to persist with this action
    • BuildAction

      public BuildAction(Run<?,?> owner, T result, boolean canSerialize)
      Creates a new instance of BuildAction.
      Parameters:
      owner - the associated build that created the result
      result - the result to persist with this action
      canSerialize - determines whether the result should be persisted in the build folder
  • Method Details

    • createXmlStream

      protected abstract AbstractXmlStream<T> createXmlStream()
      Creates the XML stream to read the results. This method is invoked by the constructor in this BuildAction 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

      public Run<?,?> getOwner()
    • onAttached

      public void onAttached(Run<?,?> r)
      Specified by:
      onAttached in interface RunAction2
    • onLoad

      public void onLoad(Run<?,?> r)
      Specified by:
      onLoad in interface RunAction2
    • readResolve

      protected Object readResolve()
      Called after de-serialization to improve the memory usage.
      Returns:
      this
    • getProjectActions

      public Collection<? extends Action> getProjectActions()
      Specified by:
      getProjectActions in interface SimpleBuildStep.LastBuildAction
    • createProjectAction

      protected abstract JobAction<? extends BuildAction<T>> createProjectAction()
    • getResult

      public T getResult()
      Returns the repository statistics. Since the object requires some amount of memory, it is stored in a WeakReference. 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

      protected abstract String getBuildResultBaseName()
    • getBuildActionFromHistoryStartingFrom

      public static <T extends BuildAction<?>> Optional<T> getBuildActionFromHistoryStartingFrom(@CheckForNull Run<?,?> baseline, Class<T> buildActionClass)
      Returns a BuildAction 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 a BuildAction then an empty result is returned.
      Type Parameters:
      T - type of the results
      Parameters:
      baseline - the baseline to start the search with
      buildActionClass - the type of the action to find
      Returns:
      the next available BuildAction, or an empty result if there is no such action