Delete all user repositories from bitbucket (stash)

As contractors come and go, we end up with dead forks in Stash.  That is, forks in user repositories that are never going to be incorporated.  We would like to delete all repositories in the user's personal space.

Our users are configured using LDAP. Once the user is dropped from LDAP, the user is no longer visible in the user's admin page of Stash.  However, we can still go to the users list of repositories via http://stash/users/user_name.

Is there a convenient way to remove all personal repositories for these users?

6 answers

There isn't a convenient way -  at least no way I know.

As a central git-server is generally used as a long-time archive, there even shouldn't be a convenient way IMHO to do mass destruction operations (which might be easily done by incident ...)

You might achieve your goal using the REST API.This needs a little scripting, but should be easy enough though.


@michael_giroux: "Once the user is dropped from LDAP, the user is no longer visible in the user's admin page of Stash"

Just for information: This is the only way to free the Bitbucket-licenses of LDAP users. Each LDAP user is able to login into Bitbucket server. As soon as the LDAP user initially logs in, he eats up one license out of your license pool. Bitbucket does not offer a possibility to remove the user from the license pool again to free the license (as can be done with Internal Bitbucket Users). The only way to free licenses of LDAP users is removing them from LDAP - after this Bitbucket automatically should free the users license.

We have our server configured so that only members of a particular AD group can login to Stash, and removing them from that group frees up the license.

The license is not the issue.  Some of these folks forked several repos, and/or created their own repositories.  We want to every repository created by a contractor once they are removed from LDAP.


Johannes Kilian has proposed a nice solution using the Rest API.  We will look into that.

yeah, I know licenses weren't your issue, but Johannes's aside about deleting accounts from LDAP being the only way to retrieve licenses seemed odd to me.

I just wanted to point out, how "freeing licenses when using LDAP" works ...- I was aware that was not part of @michael_giroux's question - therefore I added it as a comment - and not as an answer wink

Tim Crall: Thanks - wasn't aware of this. My insights have been a result of discussion on As I don't have access on our ActiveDirectory contents, the dynamic "Separate Group" solution is not a way to go for me yet sad


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

655 views 5 9
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