To automate deployment, I need to provide a URL to a file on BitBucket Download.
As the receiving service has no functionality to add a header, the authentication must be included in the URL.
For the upload, I can include credentials in this schema (found here, Step 3b):
https://${BITBUCKET_USERNAME}:${BITBUCKET_APP_PASSWORD}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads
However, this seems not possible for the download of a file. I tried this schema:
https://${BITBUCKET_USERNAME}:${BITBUCKET_APP_PASSWORD}@api.bitbucket.org/2.0/repositories/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}/downloads/build.zip
In this very old post, it sounds like there is a way to get a generated URL, with a 24h-token.
This would be the perfect fit for this use case.
Thank you for any hint!
Hey Robin,
Files cannot be downloaded by navigating directly to a URL for the Downloads section of a Bitbucket Repo.
This is because the default method for authentication over HTTPS is username/password which has been deprecated.
You will need to make use of a cURL command to handle this, for example:
curl -L -u username:AppPassword https://api.bitbucket.org/2.0/repositories/{workspace_ID}/{repository_slug}/downloads/filename.ext --output filename.ext
Hope this helps.
Cheers!
- Ben (Bitbucket Cloud Support)
Hey Ben
Thank you for your response.
The only option i have is to send one URL where the service downloads the build. So this doesn't help in this case.
I don't understand why it is not implemented to authenticate this way for the download as it is already possible for the upload.
Thank you & best regards
Robin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin,
The above that I have specified is to download particular files from the Downloads directory, so apologies for the confusion.
I have tested the below URL format to download builds (ie certain commit hashes) and this has worked from my end - if it does not I would suggest double checking the App Password and updating it if this is not correct:
https://{BITBUCKET_USERNAME}:{BITBUCKET_APP_PASSWORD}@bitbucket.org/{WORKSPACEID}/{REPOSLUG}/get/{COMMITHASH}.zip
Hope this helps.
Cheers!
- Ben (Bitbucket Cloud Support)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Really helpful.
Thank you Ben!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.