The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Dominic Vallejo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 21, 2018

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Answer accepted
Steven Whitman
Contributor
February 22, 2018

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.

Muniraja SREERAM
October 8, 2019

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

Steven Whitman
Contributor
October 10, 2019

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.

0 votes
Muniraja SREERAM
October 8, 2019

Bitbucket Cloud REST API version 1 is deprecated 

TAGS
AUG Leaders

Atlassian Community Events