Store and retrieve artifacts

5 minute read

Upload artifacts to and download them from external storage using CloudBees actions for Amazon S3 and JFrog Artifactory. These actions wrap standard storage operations with optional artifact registration so stored files become trackable in CloudBees Unify. Refer to Understanding artifact management for an overview of how storage fits into the artifact lifecycle.

S3 actions require AWS credentials to be configured before use. Refer to Configure AWS credentials.

Store an object on Amazon S3

Use the cloudbees-io/s3-upload-object action to upload a file to Amazon S3. Set send-artifact-info: true to register the uploaded file as a trackable artifact in CloudBees Unify.

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

Automatic artifact data reporting

This action reports artifact-related data to the workflow run for artifact traceability purposes.

Do not include the Register and track artifacts action for the same artifact version, as the resulting run would register duplicate artifact entries to CloudBees Unify.

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 CloudBees Unify. Defaults to the filename if not provided.

artifact-version

String

No

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

send-artifact-info

Boolean

No

If true, sends artifact information to CloudBees Unify for artifact traceability purposes. Default is false.

commit

String

No

The commit ID from the source repository, used when registering the build artifact in CloudBees Unify. Default is ${{ cloudbees.scm.sha }}.

ref

String

No

The ref or branch of the source repository, used when registering the build artifact in CloudBees Unify. Default is ${{ cloudbees.scm.ref }}.

repository-url

String

No

The clone URL of the source repository, used when registering the build artifact in CloudBees Unify. Default is ${{ cloudbees.scm.repositoryUrl }}.

component-id

String

No

The ID of the component associated with the artifact. Defaults to the component of the current workflow run (${{ cloudbees.component.id }}).

Output: artifact-id (String): the unique identifier of the artifact reported to CloudBees Unify. Only populated when send-artifact-info: true.

Usage examples

Basic example

- 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

With artifact registration

- 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

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 }}"

Retrieve an object from Amazon S3

Use the cloudbees-io/s3-download-object action to download a file from Amazon S3.

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

Inputs

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

bucket-name

String

Yes

The Amazon S3 bucket name.

file-path

String

Yes

The destination path for the download.

s3-path

String

Yes

The Amazon S3 bucket file path of the object to be downloaded.

Usage example

- name: Download from Amazon S3 uses: cloudbees-io/s3-download-object@v1 with: file-path: /local-image.tar bucket-name: Amazon_S3_bucket_name s3-path: amazon-s3-image.tar

Upload a file to JFrog Artifactory

Use the cloudbees-io/jfrog-artifactory-upload-file action to upload a file to the JFrog Artifactory repository manager. Authenticate with either a token or a username and password. Set send-artifact-info: true to register the uploaded file as a trackable artifact in CloudBees Unify.

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

Automatic artifact data reporting

This action reports artifact-related data to the workflow run for artifact traceability purposes.

Do not include the Register and track artifacts action for the same artifact version, as the resulting run would register duplicate artifact entries to CloudBees Unify.

Inputs

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

artifactory-path

String

Yes

The JFrog Artifactory destination path for the upload.

file-path

String

Yes

The path of the file to be uploaded.

url

String

Yes

The JFrog Artifactory server URL.

token

String

Required only if username and password are not specified.

The JFrog Artifactory token.

username

String

Required only if token is not specified.

The JFrog Artifactory username.

password

String

Required only if token is not specified.

The JFrog Artifactory password.

artifact-name

String

No

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

artifact-version

String

No

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

send-artifact-info

Boolean

No

If true, sends artifact information to CloudBees Unify for artifact traceability purposes. Default is false.

commit

String

No

The commit ID from the source repository, used when registering the build artifact in CloudBees Unify. Default is ${{ cloudbees.scm.sha }}.

ref

String

No

The ref or branch of the source repository, used when registering the build artifact in CloudBees Unify. Default is ${{ cloudbees.scm.ref }}.

repository-url

String

No

The clone URL of the source repository, used when registering the build artifact in CloudBees Unify. Default is ${{ cloudbees.scm.repositoryUrl }}.

Output: artifact-id (String): the unique identifier of the artifact reported to CloudBees Unify. Only populated when send-artifact-info: true.

Usage examples

With token authentication

- name: Upload file to JFrog Artifactory uses: cloudbees-io/jfrog-artifactory-upload-file@v1 with: artifactory-path: my-image.tar file-path: /local-path url: ${{ JFROG_URL }} token: ${{ secrets.JFROG_TOKEN }}

With username and password authentication, and artifact registration

- name: Upload file to JFrog Artifactory uses: cloudbees-io/jfrog-artifactory-upload-file@v1 with: artifactory-path: test-image.tar file-path: /local-path url: ${{ JFROG_URL }} username: ${{ secrets.JFROG_USERNAME }} password: ${{ secrets.JFROG_PASSWORD }} artifact-name: my-artifact artifact-version: 1.0.0 send-artifact-info: true

Full workflow example

name: jfrog-artifactory-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: JFrog Artifactory upload file id: jfrog-upload uses: cloudbees-io/jfrog-artifactory-upload-file@v1 with: artifactory-path: my-repo/my-jfrog/test.zip file-path: ${{ cloudbees.workspace }}/my-files/for-upload.zip url: ${{ vars.JFROG_URL }} username: ${{ vars.JFROG_USERNAME }} password: ${{ secrets.JFROG_PASSWORD }} artifact-name: my-artifact artifact-version: 1.0.0 send-artifact-info: true - name: Print output parameter artifact ID from JFrog upload action uses: docker://alpine:latest shell: sh run: | echo "artifact ID for my-artifact:1.0.0 at my-repo/my-jfrog/test.zip is: ${{ steps.jfrog-upload.outputs.artifact-id }}"

Download a file from JFrog Artifactory

Use the cloudbees-io/jfrog-artifactory-download-file action to download a file from the JFrog Artifactory repository manager. Authenticate with either a token or a username and password.

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

Inputs

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

url

String

Yes

The JFrog Artifactory server URL.

token

String

Required only if username and password are not specified.

The JFrog Artifactory token.

username

String

Required only if token is not specified.

The JFrog Artifactory username.

password

String

Required only if token is not specified.

The JFrog Artifactory password.

file-path

String

Yes

The destination path for the download.

artifactory-path

String

Yes

The JFrog Artifactory file path of the object to be downloaded.

Usage example

- name: Download file from JFrog Artifactory uses: https://github.com/cloudbees-io/jfrog-artifactory-download-file@v1 with: url: ${{ JFROG_URL }} token: ${{ secrets.JFROG_TOKEN }} file-path: /local-path artifactory-path: test-image.tar