TeamCity S3 Artifact Storage Plugin

official project License

This plugin allows replacing the TeamCity built-in artifacts storage with AWS S3. The artifacts storage can be changed at the project level. After changing the storage, new artifacts produced by the builds of this project will be published to the (specified) AWS S3 bucket. Besides publishing, the plugin also implements resolving of artifact dependencies and clean-up of build artifacts.

State

Baseline functionality finished. Feedback wanted.

Compatibility

The plugin is compatible with TeamCity 2017.1 and greater

Features

When installed and configured, the plugin:

Download

You can download the plugin and install it as an additional TeamCity plugin. The latest plugin builds:

Branch Status Download TeamCity
master Download 2019.2-SNAPSHOT
Jaipur-2018.1.x Download 2018.1.x
Indore-2017.2.x Download 2017.2.x
Indore-2017.1.x Download 2017.1.1+

Installing

See instructions in TeamCity documentation.

Configuring

The plugin adds the Artifacts Storage tab to the Project Settings page in the TeamCity Web UI. The tab lists the built-in TeamCity artifacts storage displayed by default and marked as active.

To configure Amazon S3 storage for TeamCity artifacts, perform the following:

  1. Select S3 Storage as the storage type.
  2. Provide an optional name for your storage.
  3. Select an AWS region.
  4. Provide your AWS Security Credentials.
  5. Specify an existing S3 bucket to store artifacts.
  6. Save your settings.
  7. The configured S3 storage will appear on the Artifacts storage page. Make it active using the corresponding link.

Now the artifacts of this project, its subprojects, and build configurations will be stored in the configured storage.

Permissions

The plugin requires to have the following S3 permissions:

Note: When pre-signed URLs option is enabled you need to grant required build agent permissions to the TeamCity server machine.

Known issues

Bad Request (400) from S3 when downloading artifact from TeamCity in "ant get" task using basic http auth scheme (httpAuth prefix in URL)

Error message returned from AWS: Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified

Workaround: use pure 'curl -L'

Build agents fails to fetch artifacts from S3

Failed to resolve artifact dependency X: Failed to download file 'X': Failed to download https://teamcity/X.tar]: Illegal status [403] while downloading https://s3.X.amazonaws.com/bucket/X?...: Forbidden (jetbrains.buildServer.artifacts.impl.SourcePathAwareResolvingFailedException)

This can occur if the build agent is not able to fetch the artifact from the presigned URL generated by TeamCity within the time limit which is default 60s.

This value can be modified by setting a internal TeamCity server property storage.s3.url.expiration.time.seconds.

Building

To build the plugin locally run the following command in the plugin root directory:

> gradle build

The plugin artifact will be produced in the following location s3-artifact-storage-server/build/distributions/s3-artifact-storage.zip and could be installed as an external TeamCity plugin.