Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket Pipelines not uploading the file to the "Downloads" page

So I have been trying to have my build artifacts uploaded from Bitbucket Pipelines straight to the Bitbucket Downloads page.

My build process generates a .tar file with all the artifacts, and then I try, via curl, to upload it. The curl runs, it even shows the progress, and the pipeline ends successfully.

Here is the curl and the outcome:

curl -X POST https ://${BB_AUTH_STRING}@api.bitbucket.org/2.0/repositories/mycompany/myrepository/downloads --form files=@"artifact.tar"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                             Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 1890k    0     0  100 1890k      0  11.0M --:--:-- --:--:-- --:--:-- 10.9M

I tried using variables for the repository name and using just the raw values. Either way, same outcome. The build is successful but the Downloads page is still empty. Can you help me on this?

EDIT: Just found out the reason. The thing is that curl fails silently. I've added a -v flag and found out that I was having authentication issues. So, for those who are having issues with curl, please don't forget to add the -v (which should have been the first thing that I tried).

like image 651
Diego Martins Avatar asked Nov 15 '25 20:11

Diego Martins


1 Answers

I hit this issue too. I got it working using this command:

curl -s -u "${BITBUCKET_REPO_OWNER}:${BB_AUTH_STRING}" -X POST "https://api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads" -F files="@${ARTIFACT_NAME}" --verbose

In my case ARTIFACT_NAME is the name of the file I upload. Note that the file name gets prefixed with the @ in the command. The file name in the dir being uploaded just matches ARTIFACT_NAME though.

I also found that it was important to split out the user and password into the -u piece of the command. For one reason or another I wasn't able to get it working when including them in the url to post to like the documentation state.

Full details are on this page, however the command they provide didn't work for me.

https://confluence.atlassian.com/bitbucket/deploy-build-artifacts-to-bitbucket-downloads-872124574.html


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!