size of stash repositories via rest

we've got a large number of repos and I would like to get an overview of the sizes of each of these repos. Is there a way to get the repository size available under settings/repository details via REST API call?

2 answers

1 accepted

Hi Robbin,

Unfortunately that information isn't directly accessible via any Stash REST API:

It would be trivial to add this to a plugin - you just need to expose this method:

https://developer.atlassian.com/static/javadoc/stash/latest/api/reference/com/atlassian/stash/repository/RepositoryService.html#getSize%28com.atlassian.stash.repository.Repository%29

Let me know if you're interesting, I'm happy to show you how this could be done.

Cheers,

Charles

hi, I tried last time to write plugins, and currently I simply don't have the time right now to learn java, eclipse, maven etc all things that are needed to write plugins. If you can show me to to get the repository size count from stash that would be appreciated.

that was exactly what I needed! Could be nice if the rawSize and size were parameters for /rest/reposize/latest/projects/$proj/repos/$repo, but this absolutely works! thank you, it's very much appreciated.

Hi Robbin, what do you mean parameters sorrry?

what I mean was that it would be nice it sizeRaw and size were part of the json parameters returned by /rest/api/1.0/projects/$prj/repos/$repo, but your solution works excellent. And I do appreciate the example source code, I'll have a look at it when time allows and see if I can pick up writing plugins.

might be my vault, my brain hurts from trying to juggle to many tasks at the same time.

My first thought was to look for repository sizes when doing for example: "curl https://stash.silabs.com/rest/api/1.0/projects/cad/repos/gitbm". I was hoping that sizeRaw and size would have been part of the json string returned.

My apologies Robbin, I'm a little slow this morning, I'm still not sure what you mean (and would like to). Could you show me an example of the JSON output you were thinking of?

Ohhh. Now I see.

Yeah that's not really possible in a plugin - I would have to update core Stash (and then you would have to wait for the next release). Given that getting the size of the repository is not cheap/free I suspect that's not likely to happen. Sorry. :(

ok, perhaps it might become available as /rest/api/1.0/projects/{}/repos/{}/size or /rest/api/1.0/projects/{}/repos/{}/settings one day. Until then I'm good with this plugin.

Does this plugin still work with the newer 5.x versions of Bitbucket?

Looks like bit bucket makes following simple AJAX call (http get) when it tries to get the aprox size on it's UI:

https://<Git URL>/projects/<project name>/repos/<repo name>/sizes

It can easily be converted to a curl and can work as an API...

Yes this is do-able gives back the following json

{u'attachments': 0, u'repository': 642}

 

Thanks for the answer, i guess this can change at any time but it's better than nothing.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

706 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot