Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to download a file from private repository using curl Edited

Hi,

Is there a way to download a file from a private repository using curl or wget?

I'm getting a 401 when hitting below URL. The app password got only read permissions to Repository and I wonder if this is enough or the URL is correct. I can't use the RAW file as the URL to RAW version is changing unless there is URL to always get the RAW version of the file?

curl -s -S --user username:apppassword -L -O https://bitbucket.org/<ORG_NAME>/<REPO>/src/master/<FOLDER>/file.txt

In a browser this will display the file and the website itself so it might not be a good way of doing it but I can't find a correct API URL.

Update: I found a correct URL for the latest RAW file but I always get 401 with curl/wget and an apppassword. What permissions app password needs to get this file?

1 answer

Ok found a "correct" way to do it. "Correct" as you shouldn't use passwords in a bash like that.

curl -s -S --user username:apppassword -L -O https://api.bitbucket.org/2.0/repositories/<ORGANISATION>/<REPO>/src/master/<FOLDER>/<FILE>

Thanks! I have the same question. This worked for me, as well. 

One way to import passwords to a bash script is from an external file.

 

script.sh

#!/bin/bash

source passwords.txt

curl -s -S --user ${USER}:${APP_PASSWORD} -L -O https://api.bitbucket.org/2.0/repositories/<ORGANISATION>/<REPO>/src/master/<FOLDER>/<FILE>

 

passwords.txt

USER="username"

APP_PASSWORD="password"

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,849 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you