Class S3ArtifactHandler
- java.lang.Object
-
- com.atlassian.bamboo.build.artifact.AbstractArtifactHandler
-
- com.atlassian.bamboo.build.artifact.AbstractRepublishingArtifactHandler
-
- com.atlassian.bamboo.build.artifact.S3ArtifactHandler
-
- All Implemented Interfaces:
ArtifactHandler
,RepublishingArtifactHandler
,InitablePluginModule<ArtifactHandlerModuleDescriptor>
,BambooPluginModule
public class S3ArtifactHandler extends AbstractRepublishingArtifactHandler implements RepublishingArtifactHandler
-
-
Field Summary
Fields Modifier and Type Field Description static int
AWS_BULK_DELETE_LIMIT
-
Fields inherited from class com.atlassian.bamboo.build.artifact.AbstractRepublishingArtifactHandler
fallbackArtifactHandler
-
Fields inherited from class com.atlassian.bamboo.build.artifact.AbstractArtifactHandler
ALL_AGENT_TYPES, LOCAL_AGENTS, NON_LOCAL_AGENTS
-
Fields inherited from interface com.atlassian.bamboo.build.artifact.ArtifactHandler
LAN_SPEED, LOCAL_SPEED, NEVER_ARCHIVE, WAN_SPEED
-
-
Constructor Summary
Constructors Constructor Description S3ArtifactHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canHandleArtifact(ArtifactDefinitionContext artifact, Map<String,String> artifactHandlersConfiguration)
protected void
deleteAllFilesWithMatchingDirectoryPrefix(com.amazonaws.services.s3.AmazonS3 s3Client, String bucketName, String artifactKey)
@Nullable ArtifactLinkDataProvider
getArtifactLinkDataProvider(Artifact artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
ArtifactLinkDataProvider
getArtifactLinkDataProvider(ArtifactLink artifactLink, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
long
getMaxUnarchivedFilesPerArtifact(@NotNull Map<String,String> artifactHandlersConfiguration)
Returns the maximum number of files that can exist per artifact which will not be compressed and combined into a single archive.int
getSpeed(@NotNull Map<String,String> artifactHandlersConfiguration)
Return approximate transfer speed of this artifact handler in bytes per second for the specified configuration.boolean
isRepublishingSupported()
If republishing is really supported.boolean
moveArtifactToGlobalStorage(@NotNull Artifact artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Move artifact to a 'global storage'.@NotNull ArtifactHandlerPublishingResult
publish(@NotNull ResultKey resultKey, @NotNull ArtifactDefinitionContext artifact, @NotNull ArtifactPublishingConfig artifactPublishingConfig, @Nullable BuildLogger buildLogger)
void
removeAllArtifactsOfChain(@NotNull PlanKey planKey, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for all results of a single chain.void
removeArtifactFromStorage(@NotNull Artifact artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single artifact.void
removeArtifactFromStorage(@NotNull PlanResultKey planResultKey, @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single artifact.void
removeArtifactFromStorage(@NotNull ResultKey planResultKey, @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single artifact.void
removeArtifactsFromStorage(@NotNull PlanKey planKey, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for all results of a single chain or job.void
removeArtifactsFromStorage(@NotNull PlanResultKey planResultKey, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Removes artifact files for a single plan result.@NotNull ArtifactHandlerPublishingResult
republish(@NotNull ArtifactHandlerPublishingResult previousPublishingResult, @NotNull ResultKey resultKey, @NotNull ArtifactDefinitionContext artifact, @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider, @Nullable BuildLogger buildLogger)
Method called when remote agent tries to recover from result publishing failures.@NotNull ArtifactRetrievalStatus
retrieve(@NotNull ResultKey clientKey, @NotNull Artifact artifact, @NotNull ArtifactSubscriptionContext artifactSubscription, @NotNull ArtifactRetrievalConfig artifactRetrievalConfig)
Retrieve arbitraryArtifact
.-
Methods inherited from class com.atlassian.bamboo.build.artifact.AbstractRepublishingArtifactHandler
checkIfNothingWasPublished, copyToFallbackStorageIfDeferred, getFileSetFromFallbackStorage, makeNotNull
-
Methods inherited from class com.atlassian.bamboo.build.artifact.AbstractArtifactHandler
configProvider, configProvider, getConfigurationKey, getConfigValue, getDefaultConfiguration, getModuleDescriptor, getSupportedAgents, init
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.build.artifact.ArtifactHandler
getDefaultConfiguration, getModuleDescriptor, getSupportedAgents, publish
-
Methods inherited from interface com.atlassian.bamboo.build.artifact.RepublishingArtifactHandler
republish
-
-
-
-
Field Detail
-
AWS_BULK_DELETE_LIMIT
public static final int AWS_BULK_DELETE_LIMIT
- See Also:
- Constant Field Values
-
-
Method Detail
-
publish
@NotNull public @NotNull ArtifactHandlerPublishingResult publish(@NotNull @NotNull ResultKey resultKey, @NotNull @NotNull ArtifactDefinitionContext artifact, @NotNull @NotNull ArtifactPublishingConfig artifactPublishingConfig, @Nullable @Nullable BuildLogger buildLogger) throws Exception
- Specified by:
publish
in interfaceArtifactHandler
- Throws:
Exception
-
republish
@NotNull public @NotNull ArtifactHandlerPublishingResult republish(@NotNull @NotNull ArtifactHandlerPublishingResult previousPublishingResult, @NotNull @NotNull ResultKey resultKey, @NotNull @NotNull ArtifactDefinitionContext artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider, @Nullable @Nullable BuildLogger buildLogger) throws Exception
Description copied from interface:RepublishingArtifactHandler
Method called when remote agent tries to recover from result publishing failures. It is called if the previous attempt of transferring the artifact returned statusArtifactHandlerPublishingResult.Status.DEFERRED
.- Specified by:
republish
in interfaceRepublishingArtifactHandler
- Throws:
Exception
-
isRepublishingSupported
public boolean isRepublishingSupported()
Description copied from interface:RepublishingArtifactHandler
If republishing is really supported. Necessary because of handlers that wrap other handlers.- Specified by:
isRepublishingSupported
in interfaceRepublishingArtifactHandler
- Returns:
- true iff republishing is actually supported
-
canHandleArtifact
public boolean canHandleArtifact(ArtifactDefinitionContext artifact, Map<String,String> artifactHandlersConfiguration)
- Specified by:
canHandleArtifact
in interfaceArtifactHandler
- Overrides:
canHandleArtifact
in classAbstractArtifactHandler
-
moveArtifactToGlobalStorage
public boolean moveArtifactToGlobalStorage(@NotNull @NotNull Artifact artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider) throws IOException
Description copied from interface:ArtifactHandler
Move artifact to a 'global storage'. Artifacts in 'global storage' should only be removed whenArtifactHandler.removeArtifactFromStorage(Artifact, ArtifactHandlerConfigProvider)
is called. It is not a requirement to physically move the files as long as the above contract is fulfilled.- Specified by:
moveArtifactToGlobalStorage
in interfaceArtifactHandler
- Returns:
- true if move successful
- Throws:
IOException
-
retrieve
@NotNull public @NotNull ArtifactRetrievalStatus retrieve(@NotNull @NotNull ResultKey clientKey, @NotNull @NotNull Artifact artifact, @NotNull @NotNull ArtifactSubscriptionContext artifactSubscription, @NotNull @NotNull ArtifactRetrievalConfig artifactRetrievalConfig) throws IOException
Description copied from interface:ArtifactHandler
Retrieve arbitraryArtifact
. Artifact is found by the information in artifact parameter.- Specified by:
retrieve
in interfaceArtifactHandler
- Parameters:
clientKey
- identifier of plan or deployment doing the downloadartifact
- artifact informationartifactSubscription
- download details (e.g. target path, copy pattern)artifactRetrievalConfig
- handler specific configuration- Throws:
IOException
-
getSpeed
public int getSpeed(@NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
Description copied from interface:ArtifactHandler
Return approximate transfer speed of this artifact handler in bytes per second for the specified configuration. Result of this method might be taken into account when deciding which artifact handler to use if multiple handlers are enabled.- Specified by:
getSpeed
in interfaceArtifactHandler
- Parameters:
artifactHandlersConfiguration
- artifact handler configuration- Returns:
- approximate transfer speed in Bps, for example:
ArtifactHandler.LOCAL_SPEED
,ArtifactHandler.LAN_SPEED
,ArtifactHandler.WAN_SPEED
-
removeArtifactFromStorage
public void removeArtifactFromStorage(@NotNull @NotNull Artifact artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single artifact.- Specified by:
removeArtifactFromStorage
in interfaceArtifactHandler
-
removeArtifactFromStorage
public void removeArtifactFromStorage(@NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single artifact. Called when removingArtifactLink
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactFromStorage
in interfaceArtifactHandler
-
removeArtifactFromStorage
public void removeArtifactFromStorage(@NotNull @NotNull ResultKey planResultKey, @NotNull @NotNull ImmutableArtifactDefinitionBase artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single artifact. Called when removingArtifactLink
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactFromStorage
in interfaceArtifactHandler
-
removeArtifactsFromStorage
public void removeArtifactsFromStorage(@NotNull @NotNull PlanResultKey planResultKey, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for a single plan result. Called when removingResultsSummary
Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactHandler
-
removeArtifactsFromStorage
public void removeArtifactsFromStorage(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
Removes artifact files for all results of a single chain or job. Called when removingPlan
Calling it for chain removes only the shared artifacts. Should not remove artifacts that were moved to global storage.- Specified by:
removeArtifactsFromStorage
in interfaceArtifactHandler
-
removeAllArtifactsOfChain
public void removeAllArtifactsOfChain(@NotNull @NotNull PlanKey planKey, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
Description copied from interface:ArtifactHandler
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 interfaceArtifactHandler
-
deleteAllFilesWithMatchingDirectoryPrefix
protected void deleteAllFilesWithMatchingDirectoryPrefix(com.amazonaws.services.s3.AmazonS3 s3Client, String bucketName, String artifactKey)
-
getArtifactLinkDataProvider
public ArtifactLinkDataProvider getArtifactLinkDataProvider(ArtifactLink artifactLink, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
- Specified by:
getArtifactLinkDataProvider
in interfaceArtifactHandler
-
getArtifactLinkDataProvider
@Nullable public @Nullable ArtifactLinkDataProvider getArtifactLinkDataProvider(Artifact artifact, @NotNull @NotNull ArtifactHandlerConfigProvider artifactHandlerConfigProvider)
- Specified by:
getArtifactLinkDataProvider
in interfaceArtifactHandler
-
getMaxUnarchivedFilesPerArtifact
public long getMaxUnarchivedFilesPerArtifact(@NotNull @NotNull Map<String,String> artifactHandlersConfiguration)
Description copied from interface:ArtifactHandler
Returns the maximum number of files that can exist per artifact which will not be compressed and combined into a single archive. If the threshold is exceeded, artifacts will be packaged into a single file before publishing.
ArtifactHandler
does not need to treat archived artifacts differently - from ArtifactHandler perspective the packaging is transparent. Artifact files will be compressed before invoking #publish method and decompressed after invoking #retrieve method.This method should return
ArtifactHandler.NEVER_ARCHIVE
if packaging of artifacts is disabled, to always send files unarchived.- Specified by:
getMaxUnarchivedFilesPerArtifact
in interfaceArtifactHandler
- Overrides:
getMaxUnarchivedFilesPerArtifact
in classAbstractArtifactHandler
- Parameters:
artifactHandlersConfiguration
- artifact handler configuration- Returns:
- maximum number of files per artifact that should not be packaged into a single file
-
-