Class BuildSelector

java.lang.Object
hudson.model.AbstractDescribableImpl<BuildSelector>
hudson.plugins.copyartifact.BuildSelector
All Implemented Interfaces:
ExtensionPoint, Describable<BuildSelector>
Direct Known Subclasses:
DownstreamBuildSelector, LastBuildWithArtifactSelector, LastCompletedBuildSelector, ParameterizedBuildSelector, PermalinkBuildSelector, SavedBuildSelector, SpecificBuildSelector, StatusBuildSelector, TriggeredBuildSelector, WorkspaceSelector

public abstract class BuildSelector extends AbstractDescribableImpl<BuildSelector> implements ExtensionPoint
Extension point for selecting the build to copy artifacts from. In a subclass override just isSelectable() for a standard loop through completed builds, starting with the most recent. Otherwise override getBuild() to provide different build selection logic.
Author:
Alan Harder
  • Constructor Details

    • BuildSelector

      public BuildSelector()
  • Method Details

    • getBuild

      public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter, Run<?,?> parent)
      Find a build to copy artifacts from.
      Parameters:
      job - Source project
      env - Environment for build that is copying artifacts
      filter - Additional filter; returned result should return true (return null otherwise)
      parent - Build to which artifacts are being copied
      Returns:
      Build to use, or null if no appropriate build was found
    • getBuild

      @Deprecated public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter)
      Deprecated.
      Find a build to copy artifacts from. Older and deprecated version of API.
      Parameters:
      job - Source project
      env - Environment for build that is copying artifacts
      filter - Additional filter; returned result should return true (return null otherwise)
      Returns:
      Build to use, or null if no appropriate build was found
    • isSelectable

      protected boolean isSelectable(Run<?,?> run, EnvVars env)
      Should this build be selected? Override just this method to use a standard loop through completed builds, starting with the most recent.
      Parameters:
      run - Build to check
      env - Environment for build that is copying artifacts
      Returns:
      True to select this build
    • isBuildResultBetterOrEqualTo

      protected static boolean isBuildResultBetterOrEqualTo(Run<?,?> run, Result resultToTest)
      Wrapper for Result.isBetterOrEqualTo(Result) with null checks. Returns false if run is null or run is still running.
      Parameters:
      run - Build to test.
      resultToTest - Result to test.
      Returns:
      false if run is null or run is still running.
      See Also:
    • getArtifacts

      @CheckForNull protected VirtualFile getArtifacts(Run<?,?> sourceBuild, PrintStream console) throws IOException, InterruptedException
      Load artifacts from a given build.
      Parameters:
      sourceBuild - a build which may have associated artifacts
      console - a way to print messages
      Returns:
      a directory of artifacts, or null if missing
      Throws:
      IOException
      InterruptedException
    • getSourceDirectory

      @Deprecated protected FilePath getSourceDirectory(Run<?,?> src, PrintStream console) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException