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?
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 {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
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.
Bitbucket Cloud REST API version 1 is deprecated
@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.
It looks like you're new here. Sign in or register to get started.