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

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

Add a new group to all existing repos in an org?

Hi, I want to create a new read only group that id like to add to all of our existing repos without having to add them one at a time.

Is this possible?

2 answers

1 accepted

There isn't anything out of the box that I'm aware of but you could do this with either ScriptRunner to the Bitbucket REST API.  

Use this REST API to add a group to a project:

PUT: /rest/api/1.0/projects/{projectKey}/permissions/groups?permission={permission}&name={group}

Replace {projectKey} with the project's key.

Replace {permission} with PROJECT_READ, PROJECT_WRITE or PROJECT_ADMIN

Replace {group} with the name of an existing group.

Use this REST API to add a group to a repository in a project:

PUT: /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/permissions/groups?permission={permission}&name={group}

Replace {projectKey} with the project's key.

Replace {repositorySlug} with the repositories slug (typically the name of the repo with spaces replaced by hyphens).  The two rest APIs I mention below can be used to get the slugs.

Replace {permission} with REPO_READ, REPO_WRITE or REPO_ADMIN

Replace {group} with the name of an existing group.

To get the first 1000 projects on the server use:

GET: /rest/api/1.0/projects?limit=1000

And to get the first 1000 repos in the project use this:

GET: /rest/api/1.0/projects/{projectKey}/repos?limit=1000

Replace {projectKey} with the project's key which was obtained with the GET REST call above.

@Steven Whitman , It is help us if you share the new API's to add the groups to Bitbucket repositories? those API's not working what you mentioned in the solution 

We are using Bitbucket cloud.

Sorry I don't have access to Bitbucket cloud, you'd need to ask someone else what are the equivalent APIs for the cloud product.

Bitbucket Cloud REST API version 1 is deprecated 

Suggest an answer

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

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,869 views 0 7
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