How get all repositories and their URL via REST API in Stash

 

3 answers

1 accepted

This widget could not be displayed.

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. 

This widget could not be displayed.

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

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.

This widget could not be displayed.

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
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,589 views 9 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you