Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

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

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


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



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



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

183 views 0 5
Join discussion

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