Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pull a single file from BitBucket using curl

Horst Federau
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 30, 2018

I need to write a script (bash) to download a single file from a private BitBucket repo. I have done it with 'git archive', but I would like to use curl. All the tests I have done only download a file with lots of html tags in it, I never get the actual file. 

1 answer

0 votes
jredmond
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 30, 2018

There's an "open raw" option in the source view for each file in the repo:

Screen Shot 2018-11-30 at 1.38.22 PM.png

That will give you the raw file, without the additional HTML content you'd see in a browser. You can see an example of it at https://bitbucket.org/mirror/linux/raw/master/Makefile or https://bitbucket.org/mirror/linux/raw/b6839ef26e549de68c10359d45163b0cfb031183/Makefile - the first link will always take you to the latest version of that file in the master branch, and the second link will always take you to that specific commit's version of that file.

Horst Federau
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 30, 2018

Thank you Jim, I have been asked to automate the download via a bash script. The main reason is that my organization has lots of repos. All of them have a specific file I need to download to a local drive and extract some information. So, I need to go through all the repos and collect those files, so the only option is via a script so I can automate it.

Horst

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events