Upload artifacts generated from a pipelines build to another repository

Platform Notice: Cloud Only - This article only applies to Atlassian apps on the cloud platform.

Summary

This article explains how to upload a file to the downloads section of another repository using pipelines. This use case is helpful in situations where a user wishes to upload a file generated during the build process on Bitbucket pipelines to another repository.

Solution

There are API endpoints which may be used to upload files to the downloads section of another repository and also to fetch files from the other repositories download section.

Sample Script - Repository 1

image: atlassian/default-image:2 pipelines:   default:     - step:         name: Build and Test         script:           - mkdir test_folder           - cd test_folder           - echo "choose the password" > testfile.txt           - cat tetsfile.txt           - curl -u <atlassian_account_email>:<api_token> -X POST 'https://api.bitbucket.org/2.0/repositories/workspace_id/repo_slug/downloads' -F files=@testfile.txt          artifacts:           - test_folder/testfile.txt

The above piece of code uploads testfile.txt to the download section of another repository example: repo2.

Replace <atlassian_account_email> with your Atlassian account email, <api_token> with an API token for your account with the scope write:repository:bitbucket, workspace_id with the ID of the workspace where the repo belongs, repo_slug with the slug of the repo where you want to upload the file, and testfile.txt with the name of your file. 

Sample Script - Repository 2

On repo2 you may use a configuration similar to the one shown below to fetch the file from the download section of repo1:

image: atlassian/default-image:2 pipelines:   default:     - step:         - curl -O -L -u <atlassian_account_email>:<api_token> https://api.bitbucket.org/2.0/repositories/workspace_id/repo_slug/downloads/testfile.txt 

This can also be performed using the bitbucket-upload-file pipe as described below. For more information on how to use this pipe, please refer to its documentation page.

script: - pipe: atlassian/bitbucket-upload-file:0.7.5 variables: ATLASSIAN_ACCOUNT_EMAIL: $ATLASSIAN_ACCOUNT_EMAIL ATLASSIAN_API_TOKEN: $ATLASSIAN_API_TOKEN FILENAME: 'package.json' ACCOUNT: 'team-account' REPOSITORY: 'awesome-repository-name'

If the above instructions do not assist with performing the uploading/fetching of artifacts within downloads, please raise a support ticket or raise a community support ticket for further assistance with this.

Updated on September 26, 2025

Still need help?

The Atlassian Community is here for you.