CloudBees action: Store an object on Amazon S3

2 minute read

Use this action to upload an object file to Amazon Simple Storage Service (Amazon S3). This action also reports artifact-related data to the workflow run for artifact traceability purposes.

All CloudBees action repositories are listed at CloudBees, Inc. on GitHub.

Inputs

Table 1. Input details
Input name Data type Required? Description

bucket-name

String

Yes

The Amazon S3 bucket name.

file-path

String

Yes

The local file path of the directory to be uploaded.

s3-path

String

Yes

The Amazon S3 destination path for the upload.

artifact-name

String

No

The name of the artifact to send to the CloudBees platform. Defaults to the filename if not provided.

artifact-version

String

No

The version of the artifact to send to the CloudBees platform. Defaults to - if not provided.

send-artifact-info

Boolean

No

If true, sends artifact information to the CloudBees platform for artifact traceability purposes. Default value is false.

Outputs

Table 2. Output details
Output name Data type Description

artifact-id

String

The unique identifier of the artifact reported to the CloudBees platform.

Usage examples

Basic example

The following is a basic example of using the action:

- name: Upload to Amazon S3 uses: cloudbees-io/s3-upload-object@v1 with: bucket-name: amazon-s3-bucket-name file-path: my-local/my-image.tar s3-path: my-amazon-s3/s3-image.tar

Using optional inputs

The following example specifies optional inputs to report artifact data to the workflow run.

- name: Upload to Amazon S3 uses: cloudbees-io/s3-upload-object@v1 with: bucket-name: my-image.tar file-path: /local-path s3-path: my-path/to-destination artifact-name: my-artifact artifact-version: 1.0.0 send-artifact-info: true

Full workflow example

The following workflow example:

  • Checks out source code from a repository.

  • Uses the action to upload a file to Amazon S3.

  • Prints the artifact ID of the uploaded file.

name: s3-upload-file kind: workflow apiVersion: automation.cloudbees.io/v1alpha1 on: push: branches: - main jobs: upload-file-job: steps: - name: checkout-source-code uses: cloudbees-io/checkout@v1 - name: S3 upload file id: s3-upload uses: cloudbees-io/s3-upload-object@v1 with: bucket-name: my-repo/my-bucket/test.zip file-path: ${{ cloudbees.workspace }}/my-files/for-upload.zip s3-path: ${{ vars.S3_URL }} artifact-name: my-artifact artifact-version: 1.0.0 send-artifact-info: true - name: Print output parameter artifact ID from S3 upload action uses: docker://alpine:latest shell: sh run: | echo "artifact ID for my-artifact:1.0.0 at my-repo/my-bucket/test.zip is: ${{ steps.s3-upload.outputs.artifact-id }}"