Class AbstractArtifactManager
java.lang.Object
com.atlassian.bamboo.build.artifact.AbstractArtifactManager
- All Implemented Interfaces:
ArtifactManager
- Direct Known Subclasses:
LocalArtifactManager
,RemoteArtifactManager
-
Field Summary
Fields inherited from interface com.atlassian.bamboo.build.artifact.ArtifactManager
LOGS_FOR_BUILD
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected @Nullable Artifact
findMatchingArtifact
(String artifactHandlerKey, Collection<Artifact> matchingArtifacts) protected Iterable<ArtifactHandler>
getArtifactHandlers
(ArtifactDefinitionContext artifact, Map<String, String> artifactHandlersConfiguration) @NotNull List<ArtifactHandler>
getArtifactHandlersForAgent
(@NotNull AgentType agentType) Get list of enabled artifact handlers usable on agent of a given type.protected abstract void
markSubscriptionAsConsumed
(PlanResultKey planResultKey, ArtifactSubscriptionContext artifactSubscription, String linkType) void
moveArtifactToGlobalStorage
(@NotNull Artifact artifact) Move artifact to a 'global storage'.publish
(@Nullable BuildLogger buildLogger, @NotNull PlanResultKey resultKey, @NotNull File baseDirectory, @NotNull ArtifactDefinitionContext artifact, @NotNull Map<String, String> artifactHandlerConfiguration, int minExpectedFilesCnt) Request copy of artifacts from a designated location to artifact storage.publish
(@Nullable BuildLogger buildLogger, @NotNull ResultKey resultKey, @NotNull File baseDirectory, @NotNull ArtifactDefinitionContext artifact, @NotNull Map<String, String> artifactHandlerConfiguration, int minExpectedFilesCnt) Request copy of artifacts from a designated location to artifact storage.void
removeAllArtifactsOfChain
(@NotNull PlanKey planKey, @NotNull Iterable<PlanKey> jobKeys, @NotNull Map<String, String> artifactHandlersConfiguration) Removes artifact files for all results of a single chain.void
removeArtifactFromStorage
(@NotNull Artifact artifact) Removes artifact files for a single artifact.void
removeArtifactsFromStorage
(@NotNull PlanKey planKey) Removes artifact files for all results of a single.void
removeArtifactsFromStorage
(@NotNull PlanKey planKey, @NotNull Map<String, String> artifactHandlersConfiguration) Removes artifact files for all results of a single.void
removeArtifactsFromStorage
(@NotNull Iterable<ArtifactLink> artifactLinks) Removes artifact files for all plan results attached to supplied links.boolean
removeArtifactsIfOrphaned
(@NotNull List<Long> artifactIds) Removes artifacts identified by the ids on the list, but only if they are not referenced by any deployment version or build result.boolean
republish
(@Nullable BuildLogger buildLoggerArg, @NotNull ResultKey resultKey, @NotNull ArtifactPublishingResult artifactPublishingResult, @NotNull Map<String, String> artifactHandlersConfiguration) Retry publishing artifacts that are inArtifactHandlerPublishingResult.Status.DEFERRED
status.boolean
retrieve
(@Nullable BuildLogger buildLogger, @NotNull PlanResultKey planResultKey, @NotNull ArtifactSubscriptionContext artifactSubscription, @NotNull Map<String, String> artifactHandlersConfiguration, @NotNull File buildWorkingDirectory, @NotNull Multimap<String, Artifact> availableArtifacts) Retrieves a plan artifact from artifact storage.boolean
retrieve
(@Nullable BuildLogger buildLogger, @NotNull PlanResultKey planResultKey, @NotNull ResultKey resultKey, @NotNull ArtifactDefinitionContext artifactDefinitionContext, @NotNull String destinationPath, @NotNull Map<String, String> artifactHandlersConfiguration, @NotNull File buildWorkingDirectory, @NotNull Multimap<String, Artifact> availableArtifacts) Retrieves an artifact from artifact storage.final ErrorCollection
validateArtifactsSize
(@NotNull File baseDirectory, @NotNull ArtifactContext artifactContext) Validates total size of artifacts produced for single build result
-
Field Details
-
ARTIFACT_SECURITY_TOKEN
- See Also:
-
-
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 interfaceArtifactManager
- Parameters:
buildLogger
- optional, used to log messagesresultKey
- key of a plan result that created the artifactartifact
- definition of the artifactminExpectedFilesCnt
- 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 interfaceArtifactManager
- Parameters:
buildLogger
- optional, used to log messagesresultKey
- key of a plan or deployment result that created the artifactartifact
- definition of the artifactminExpectedFilesCnt
- 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 inArtifactHandlerPublishingResult.Status.DEFERRED
status. Used for recovery of build results that failed transfer.- Specified by:
republish
in interfaceArtifactManager
-
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 interfaceArtifactManager
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 interfaceArtifactManager
- Parameters:
buildLogger
- to useplanResultKey
- the plan result that contains the artifactartifactSubscription
- the artifact subscription used to identify artifactbuildWorkingDirectory
- working directory of current buildavailableArtifacts
- 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 inArtifact
object will be used to find artifact in the storage.- Specified by:
retrieve
in interfaceArtifactManager
- 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
Description copied from interface:ArtifactManager
Removes artifact files for all plan results attached to supplied links. Called when removingResultsSummary
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactManager
-
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 removingPlan
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactManager
-
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 removingChain
Should not remove artifacts that were moved to global storage.- Specified by:
removeAllArtifactsOfChain
in interfaceArtifactManager
-
removeArtifactsFromStorage
Description copied from interface:ArtifactManager
Removes artifact files for all results of a single. Called when removingPlan
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactManager
-
removeArtifactFromStorage
Description copied from interface:ArtifactManager
Removes artifact files for a single artifact.- Specified by:
removeArtifactFromStorage
in interfaceArtifactManager
-
moveArtifactToGlobalStorage
Description copied from interface:ArtifactManager
Move artifact to a 'global storage'. Artifacts in 'global storage' should only be removed whenArtifactManager.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 interfaceArtifactManager
- Throws:
IOException
-
removeOrphanedArtifacts
public boolean removeOrphanedArtifacts()- Specified by:
removeOrphanedArtifacts
in interfaceArtifactManager
- Returns:
- true if something was removed
-
removeArtifactsIfOrphaned
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 interfaceArtifactManager
- 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 interfaceArtifactManager
-