Using artifacts in steps

Artifacts are files that are produced by a step. You can share them with a following step and export them to keep the artifacts after a step completes. For example, you may wish to use reports or JAR files generated by a build step in a later deployment step. You also might like to download an artifact generated by a step, or upload it to external storage.

There are some things to remember:

  • Files that are in the BITBUCKET_CLONE_DIR at the end of a step can be configured as artifacts. The BITBUCKET_CLONE_DIR is the directory in which the repository was initially cloned.
  • You can use glob patterns to define artifacts. Glob patterns that start with a * will need to be put in quotes (keeping in mind how these react with your commands).
  • Artifact paths are relative to the BITBUCKET_CLONE_DIR.
  • Artifacts that are created in a step are available to all the following steps.
  • Artifacts will be deleted 7 days after they are generated.


In the example bitbucket-pipelines.yml file that follows, we show how to configure artifacts to share them between steps.

  • When the script for 'Build and test' completes, all files under the dist folder and the txt files in the report folder (both found under the BITBUCKET_CLONE_DIR) are kept as artifacts.
  • 'Integration test' and 'Deploy to beanstalk' can access files in dist and reports.
  • Any changes to dist or reports by 'Integration test' will not be available in 'Deploy to beanstalk' unless they are specified as artifacts in 'Integration test'.

bitbucket-pipelines.yml
pipelines:
  default:
    - step:
        name: Build and test
        image: node:8.5.0
        caches:
          - node
        script:
          - npm install
          - npm test
          - npm run build
        artifacts:
          - dist/**
          - reports/*.txt
    - step:
        name: Integration test
        image: node:8.5.0
        caches:
          - node
        services:
          - postgres
        script:
          - npm run integration-test
    - step:
        name: Deploy to beanstalk
        image: python:3.5.1
        script:
          - python deploy-to-beanstalk.py

definitions:
  services:
    postgres:
      image: postgres:9.6.4

Manual steps

Manual steps will have build artifacts produced by any previous steps copied into their working directory, similar to automatic steps.

Artifact downloads and expiry

You can download artifacts generated by a step:

  1. Select the Artifact tab of the pipeline result view
  2. Click the download icon

image of pipelines result view

Artifacts are stored for 7 days following the execution of the step that produced them. After this time, the artifacts are expired and any manual steps later in the pipeline can no longer be executed.

If you need artifact storage for longer than 7 days (or more than 1 GB), we recommend using your own storage solution, like Amazon S3 or a hosted artifact repository like JFrog Artifactory. Setting a reasonable time limit for build artifacts allows us to manage our costs so we don't have to charge for storage and transfer costs of build artifacts in Pipelines.


See these pages for more information:

Last modified on Aug 16, 2018

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.