Class AbstractArtifactManager

java.lang.Object
com.atlassian.bamboo.build.artifact.AbstractArtifactManager
All Implemented Interfaces:
ArtifactManager
Direct Known Subclasses:
LocalArtifactManager, RemoteArtifactManager

public abstract class AbstractArtifactManager extends Object implements ArtifactManager
  • Field Details

  • Constructor Details

    • AbstractArtifactManager

      public AbstractArtifactManager()
  • Method Details

    • publish

      public ArtifactPublishingResult publish(@Nullable @Nullable BuildLogger buildLogger, @NotNull @NotNull PlanResultKey resultKey, @NotNull @NotNull File baseDirectory, @NotNull @NotNull ArtifactDefinitionContext artifact, @NotNull @NotNull Map<String,String> artifactHandlerConfiguration, int minExpectedFilesCnt)
      Description copied from interface: ArtifactManager
      Request copy of artifacts from a designated location to artifact storage.
      Specified by:
      publish in interface ArtifactManager
      Parameters:
      buildLogger - optional, used to log messages
      resultKey - key of a plan result that created the artifact
      artifact - definition of the artifact
      minExpectedFilesCnt - how many files are necessary to consider the artifact complete, null if no requirements are made
      Returns:
      true if publish operation result allows the build to continue
    • publish

      public ArtifactPublishingResult publish(@Nullable @Nullable BuildLogger buildLogger, @NotNull @NotNull ResultKey resultKey, @NotNull @NotNull File baseDirectory, @NotNull @NotNull ArtifactDefinitionContext artifact, @NotNull @NotNull Map<String,String> artifactHandlerConfiguration, int minExpectedFilesCnt)
      Description copied from interface: ArtifactManager
      Request copy of artifacts from a designated location to artifact storage.
      Specified by:
      publish in interface ArtifactManager
      Parameters:
      buildLogger - optional, used to log messages
      resultKey - key of a plan or deployment result that created the artifact
      artifact - definition of the artifact
      minExpectedFilesCnt - how many files are necessary to consider the artifact complete, null if no requirements are made
      Returns:
      true if publish operation result allows the build to continue
    • republish

      public ArtifactPublishingResult republish(@Nullable @Nullable BuildLogger buildLoggerArg, @NotNull @NotNull ResultKey resultKey, @NotNull @NotNull ArtifactPublishingResult artifactPublishingResult, @NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
      Description copied from interface: ArtifactManager
      Retry publishing artifacts that are in ArtifactHandlerPublishingResult.Status.DEFERRED status. Used for recovery of build results that failed transfer.
      Specified by:
      republish in interface ArtifactManager
    • validateArtifactsSize

      public final ErrorCollection validateArtifactsSize(@NotNull @NotNull File baseDirectory, @NotNull @NotNull ArtifactContext artifactContext)
      Description copied from interface: ArtifactManager
      Validates total size of artifacts produced for single build result
      Specified by:
      validateArtifactsSize in interface ArtifactManager
      artifactContext - contains artifacts size quota if set
      Returns:
      error set in in case of exceeding quota if set
    • retrieve

      public boolean retrieve(@Nullable @Nullable BuildLogger buildLogger, @NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull ArtifactSubscriptionContext artifactSubscription, @NotNull @NotNull Map<String,String> artifactHandlersConfiguration, @NotNull @NotNull File buildWorkingDirectory, @NotNull @NotNull Multimap<String,Artifact> availableArtifacts)
      Description copied from interface: ArtifactManager
      Retrieves a plan artifact from artifact storage.
      Specified by:
      retrieve in interface ArtifactManager
      Parameters:
      buildLogger - to use
      planResultKey - the plan result that contains the artifact
      artifactSubscription - the artifact subscription used to identify artifact
      buildWorkingDirectory - working directory of current build
      availableArtifacts - artifacts found in source result
      Returns:
      true if retrieval was successful, false otherwise
    • retrieve

      public boolean retrieve(@Nullable @Nullable BuildLogger buildLogger, @NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull ResultKey resultKey, @NotNull @NotNull ArtifactDefinitionContext artifactDefinitionContext, @NotNull @NotNull String destinationPath, @NotNull @NotNull Map<String,String> artifactHandlersConfiguration, @NotNull @NotNull File buildWorkingDirectory, @NotNull @NotNull Multimap<String,Artifact> availableArtifacts)
      Description copied from interface: ArtifactManager
      Retrieves an artifact from artifact storage. The important difference for that method is, that NO subscription information is updated. Useful for retrieving artifacts in non standard way (cross-plan for example) If versionArtifacts parameter is specified, the method will first try to match requested artifact with the content of the map. If match is found, information in Artifact object will be used to find artifact in the storage.
      Specified by:
      retrieve in interface ArtifactManager
      Returns:
    • findMatchingArtifact

      @Nullable protected @Nullable Artifact findMatchingArtifact(String artifactHandlerKey, Collection<Artifact> matchingArtifacts)
    • markSubscriptionAsConsumed

      protected abstract void markSubscriptionAsConsumed(PlanResultKey planResultKey, ArtifactSubscriptionContext artifactSubscription, String linkType)
    • getArtifactHandlers

      protected Iterable<ArtifactHandler> getArtifactHandlers(ArtifactDefinitionContext artifact, Map<String,String> artifactHandlersConfiguration)
    • removeArtifactsFromStorage

      public void removeArtifactsFromStorage(@NotNull @NotNull Iterable<ArtifactLink> artifactLinks)
      Description copied from interface: ArtifactManager
      Removes artifact files for all plan results attached to supplied links. Called when removing ResultsSummary Should not remove artifacts that were moved to global storage.
      Specified by:
      removeArtifactsFromStorage in interface ArtifactManager
    • removeArtifactsFromStorage

      public void removeArtifactsFromStorage(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
      Description copied from interface: ArtifactManager
      Removes artifact files for all results of a single. Called when removing Plan Should not remove artifacts that were moved to global storage.
      Specified by:
      removeArtifactsFromStorage in interface ArtifactManager
    • removeAllArtifactsOfChain

      public void removeAllArtifactsOfChain(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull Iterable<PlanKey> jobKeys, @NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
      Description copied from interface: ArtifactManager
      Removes artifact files for all results of a single chain. Called when removing Chain Should not remove artifacts that were moved to global storage.
      Specified by:
      removeAllArtifactsOfChain in interface ArtifactManager
    • removeArtifactsFromStorage

      public void removeArtifactsFromStorage(@NotNull @NotNull PlanKey planKey)
      Description copied from interface: ArtifactManager
      Removes artifact files for all results of a single. Called when removing Plan Should not remove artifacts that were moved to global storage.
      Specified by:
      removeArtifactsFromStorage in interface ArtifactManager
    • removeArtifactFromStorage

      public void removeArtifactFromStorage(@NotNull @NotNull Artifact artifact)
      Description copied from interface: ArtifactManager
      Removes artifact files for a single artifact.
      Specified by:
      removeArtifactFromStorage in interface ArtifactManager
    • moveArtifactToGlobalStorage

      public void moveArtifactToGlobalStorage(@NotNull @NotNull Artifact artifact) throws IOException
      Description copied from interface: ArtifactManager
      Move artifact to a 'global storage'. Artifacts in 'global storage' should only be removed when ArtifactManager.removeArtifactFromStorage(Artifact) is called. It is not a requirement to physically move the files as long as the above contract is fulfilled.
      Specified by:
      moveArtifactToGlobalStorage in interface ArtifactManager
      Throws:
      IOException
    • removeOrphanedArtifacts

      public boolean removeOrphanedArtifacts()
      Specified by:
      removeOrphanedArtifacts in interface ArtifactManager
      Returns:
      true if something was removed
    • removeArtifactsIfOrphaned

      public boolean removeArtifactsIfOrphaned(@NotNull @NotNull List<Long> artifactIds)
      Description copied from interface: ArtifactManager
      Removes artifacts identified by the ids on the list, but only if they are not referenced by any deployment version or build result.
      Specified by:
      removeArtifactsIfOrphaned in interface ArtifactManager
      Returns:
      true if anything was removed
    • getArtifactHandlersForAgent

      @NotNull public @NotNull List<ArtifactHandler> getArtifactHandlersForAgent(@NotNull @NotNull AgentType agentType)
      Description copied from interface: ArtifactManager
      Get list of enabled artifact handlers usable on agent of a given type. This method should be called by agents and it doesn't filter artifact handlers according to - Bamboo instance type
      Specified by:
      getArtifactHandlersForAgent in interface ArtifactManager