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 get repository list for a stash project?

Stash project has 65+ repositories (modules) and growing. To not adjust the build process everytime a new repository is added, is there a way to query the stash project to get a listing of repositories to then input to a script to clone each at build time?

4 answers

1 accepted

0 votes
Answer accepted

I'd suggest writting a script to do the query and then filter the results down and print the output list in the format you require for your build system.

For example: You could write a get_repo_list script that takes a project name (or ~<user>) and prints all the repository slugs or the clone urls or some other simple list.

There some example code on writing oath capable REST clients for Atlassian products at:

The PERL example was written with Stash in mind (Disclaimer: I wrote it) and should be easy to use it to make such a query, parse the JSON structure into perl and then iterate over it pulling out the field you want (just make sure to handle the whole paged API thing or you only get some of the results).

Hi there Jennifer,

You can use the REST API to achieve that.

Are all repositories created by the same user?

There are some examples with the REST API that can he useful for you.

Please check them here:

The rest api for Stash core can be found here:


Celso Yoshioka

Hi Celso,

I've been playing around with the REST API using the browser there a way to limit these results to only being the "slug"?? I'm trying to use curl to get this information in a way to pass to my git clone statements.

The repos will not be created by the same user.

I also found this

but I'm not familiar on how I would construct this, public Page<? extends Repository> findByProjectKey (String projectKey, PageRequest pageRequest). Any advice?



Hi Jennifer,

Currently our REST resources don't have any notion of 'filtering' or viewing specific fields. It's all or nothing. You will have to grep or parse the results into JSON somehow.

Regarding your second question - how do you mean construct? If you're writing a Java plugin, if you have a component mentioned in atlassian-plugin.xml that can add RepositoryService to your constructor and it will be 'injected' for free. We have a few example plugins here:



Here is the way to list all public repositories in STASH project with Linux/Mac boxes,  make sure you have jq installed. 

curl -k -s https://${STASH}/rest/api/1.0/projects/|jq -r ".values[].link.url"|while read line
   #echo "curl -k -s https://${STASH}/rest/api/1.0${line}/repos"
   curl -k -s https://${STASH}/rest/api/1.0${line}/repos|jq -r ".values[].cloneUrl"

It looks like the /projects request returns the first 25 projects.  If you have more than than, you'll need to paginate through the results or change the size and limit parameters.


i am unable to list more than 25 projects , i have more than 25 . how to list them ?

should be 


Stashy (Python API client for the Atlassian Stash REST API) works very well !


Suggest an answer

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

Bitbucket Server 7.0 is here!

Hello Community, I’m Anton Genkin, a product manager on the Bitbucket Server and Data Center team and am excited to share that Bitbucket Server 7.0 is now available! It's a platform release, one th...

1,048 views 6 5
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