Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 list/pull all the files under a particular branch inside a repository via Rest Api Edited

I have to check the list of files stored under a particular branch with full path. Currently, I could not find a way of accessing it via a rest endpoint

1 answer

0 votes
Marty Atlassian Team Mar 05, 2019

Hi Tanmoy,

I am not on the Bitbucket team, but I will try to help.

Is there any reason why you need to use a REST API?

If you can use a git client then you could try something like

git ls-tree -r --name-only <branch name>

I hope that helps!

Thanks for your reply Martyn.

My branch has directories inside it. So, I want to list all the files with a relative path from the branch.

$ git ls-tree --name-only feature/API-460
.gitignore
db_connection
sql

I have some jobs that reference the branch files as part of CI.

Accessing via git command would mean that I have to install git client on the machine that wants to access bitbucket.

So, what I am trying to find is a rest-endpoint that would fetch the same result as:

$ git ls-tree -r feature/API-460

100644 blob 73febeeb4545e1 .gitignore
100755 blob 3126b0bfa7ca db_connection/conf.json
100644 blob 27a08b947d5438b0 sql/v1.0.sql
100644 blob e228c3188f92c9d96 sql/v1.1.sql
100644 blob 71ab229376c83 sql/v1.2.sql
100644 blob 39e425ba26ed91e536b sql/v1.3.sql

Like Marty likes this
Marty Atlassian Team Mar 05, 2019

Hi Tanmoy,

I think it will be simpler for you to install a git client on the machine you're using.  Then you can use git commands and shell commands to modify the output to your liking.

The only kind of REST endpoint close to what you're looking for is:

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/src#get

You would need to then call that multiple times to manually traverse the directory tree.  Ie. it will only list .gitignore, db_connection and sql in the first call.  You would then need to make a second call to list the contents of db_connection/ and a third call to list the content of sql/

I hope that helps!

Like Tanmoy Thakur likes this

Nothing more irritating then answering a question with the wrong solution, I also need to list files under a branch, and we are doing it with node.js so we need to use the bitbucket API... get lost.

Suggest an answer

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

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

270 views 2 10
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