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_DIRat the end of a step can be configured as artifacts. The
BITBUCKET_CLONE_DIRis 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
- 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
distfolder and the
txtfiles 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
- Any changes to
reportsby 'Integration test' will not be available in 'Deploy to beanstalk' unless they are specified as artifacts in 'Integration test'.
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 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:
- Select the Artifact tab of the pipeline result view
- Click the download icon
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: