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 get all repositories and their URL via REST API in Stash

 

3 answers

1 accepted

1 vote
Answer accepted
Felix Atlassian Team Aug 16, 2015

Stash's REST API uses a paged system and will, in general never just return all of something. This is to ensure performance of the system is maintained and REST requests can be processed very quickly.

You can check the REST documentation here for more info on how the paging works.

To retrieve all repositories on any given Stash instance, you would need to:

  1. GET all pages of projects from the Project REST Endpoint to retrieve all projects
  2. call the repos REST Endpoint and retrieve all pages of repositories for each project

The REST response for the repos contains that repository's clone URLs (for HTTP and SSH, depending on availability).

Another thing of note: the caller needs to have at least read access to all projects and repos for this to work. 

I have a small python script that will get you this info here.

Like Evan Slaughter likes this

Hi Felix Haehnel

Thanks for your prompt reply.

I am a Stash administrator. I want to get all none-fork repositories and backup them.

Can I use  'http://example.com/rest/api/1.0/repos' to implement.

Thank very much

Felix Atlassian Team Aug 16, 2015

Hi @Shuaibing Li, sorry for the confusion in my answer above. Yes, as you rightly pointed out, you can use the /rest/api/1.0/repos endpoint with no query parameters. That will save you having to query all the projects. That endpoint is also paged and, depending on the number of repos your Stash instance contains, you will still need to make multiple requests to retrieve all repos .

Why do you want to back up the not forked repos? Just because a repo is forked doesn't give you any kind of backup.

Stash Command Line Interface (CLI) has both getProjectList and getRepositoryList. You can also use runFromProjectList and combine that with getRepositoryList to get all repositories across all projects.

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