Deploy build artifacts to Bitbucket Downloads

Deploying the artifacts or output produced by your Bitbucket Pipelines build to Bitbucket's Downloads area is simple with Bitbucket app passwords and the Bitbucket REST API.



On this page



Step 1: Create an App password for the repository owner

Log in to Bitbucket as the repository owner (also the user who will upload the files) and go to Bitbucket Settings > App Passwords.

Create a new app password with write permissions to your repositories, and take note of the generated password that pops up. The name of the password is only for your reference, so use "Pipelines" or any other name you like.

You should now have two values that you will need for the next step.

Parameter Value
<username> Bitbucket username of the repository owner (and also the user who will upload the artifacts)
<password> App password as generated by bitbucket

Step 2: Create a Pipelines environment variable with the authentication token

Define a new secure environment variable in your Pipelines settings:

  • Parameter name: BB_AUTH_STRING
  • Parameter value: <username>:<password> (using the values from step 1)

You can define this environment variable at either the repository or account level. The example below is shown with an account environment variable.

Step 3: Deploy your artifacts using curl and the Bitbucket REST API

With the environment variable and app password in place, you can now use curl in your build script to deploy artifacts to Bitbucket via the REST API:

  curl -X POST "https://${BB_AUTH_STRING}${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"target/output.jar"


Below is a simple example from a Java project built with Maven. You should update the "target/output.jar" file name and other details to match your project.

image: maven:3.3.3

    - step:
          - mvn -B clean install
          - curl -X POST --user "${BB_AUTH_STRING}" "${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" --form files=@"target/output.jar"




Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport