Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

size of stash repositories via rest

Robbin Bonthond
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 25, 2014

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?

3 answers

1 accepted

0 votes
Answer accepted
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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

Robbin Bonthond
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014
Robbin Bonthond
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

Hi Robbin, what do you mean parameters sorrry?

Robbin Bonthond
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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.

Robbin Bonthond
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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.

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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?

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2014

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. :(

Robbin Bonthond
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 27, 2014

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.

Daniel Holmes January 12, 2018

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

3 votes
arnab January 10, 2017

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...

James Dengel February 10, 2017

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.

0 votes
Gustavo Segura May 6, 2020

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

https://github.com/gsj889/bitbucket-repo-size

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events