scriptrunner - How to get Groups name based on project key?

Qi Jiang October 4, 2017

I have project name ABC, how to get all the groups which currently have access to ABC? 

1 answer

1 accepted

0 votes
Answer accepted
Mizan
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.
October 4, 2017
Qi Jiang October 4, 2017

Will you give me a sample?

 

I was trying with code below, but no returns:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.Permissions

def project = ComponentAccessor.projectManager.getProjectObjByKey("ABC")
def result = "Groups that have Browse Project Permission for project ${project.key} <br>"
result + ComponentAccessor.permissionManager.getAllGroups(Permissions.BROWSE, project)?.collect { it.name }?.join("<br>")
Mizan
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.
October 4, 2017

Sorry I am not sure why it does not return anything. (not an expert coder)

I tried the below and it does return one group name.

def groups = ComponentAccessor.permissionManager.getAllGroups(Permissions.BROWSE, project)

return groups[0].name

 

Qi Jiang October 4, 2017

Do you have any sample for:

Collection<com.atlassian.crowd.embedded.api.Group> getAllGroups(int permissionId,
                                                                Project project)
Darshan.VPrasad October 31, 2022

Did that getallgroups calling work for you?

If yes, can share the sample?

Darshan.VPrasad November 1, 2022
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.PermissionManager


def projects = ComponentAccessor.getProjectManager()
def pm = ComponentAccessor.getPermissionManager()

projects.getProjectObjects().each() { k ->
//log.error k.key
def gl = pm.getAllGroups(0, k)
log.warn("$gl")

}

I did like this but its returning the empty list

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events