Groovy code to get users list of certain project role of Jira Project

Avin Singhal April 29, 2018

Groovy code to get users list of certain project role of Jira Project

I have a requirement of displaying the approvers name specific to project role in Jira beside the approver stage

Like for example for development role users are added to project role developers same users list need to be displayed beside  Development approve field

2 answers

Suggest an answer

Log in or Sign up to answer
2 votes
Oleksandr Chalyi November 12, 2019

I needed to get Users per Role.

ComponentManager was deprecated, use ComponentAccessor instead:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager

def projectManager = ComponentAccessor.getProjectManager()
def projectRoleManager = ComponentAccessor.getComponent (ProjectRoleManager)

// name of role here
ProjectRole devsRole = projectRoleManager.getProjectRole("Developers")

def result = ""

projectManager.getProjectObjects().each {Project project ->
ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(devsRole, project)
result += "$project.key, $, $project.lead, ${actors.getUsers()*.name}\n"

return result
0 votes
Marcos Sanchez
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.
May 2, 2018


You can try this code (based on THIS answer)

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager

ComponentManager componentManager ComponentManager.getInstance()
ProjectManager projectManager componentManager.getProjectManager()
ProjectRoleManager projectRoleManager ComponentManager.getComponentInstanceOfType(ProjectRoleManager.classas ProjectRoleManager

// name of role here
ProjectRole devsRole projectRoleManager.getProjectRole("Developers")

def result ""

projectManager.getProjectObjects().each {Project project ->
    ProjectRoleActors actors projectRoleManager.getProjectRoleActors(devsRoleproject)
    result += "$project.key, $, $project.lead, ${actors.getUsers()*.name}\n"

return result



Rao B May 12, 2021

Hello @Marcos Sanchez , @Oleksandr Chalyi 

How to get users list with direct permissions of certain project role of Jira Project.

At the moment this script is listing all users including group members.

Is there any method to list only users with direct permission from certain roles.


Thanks in advance



AUG Leaders

Atlassian Community Events