Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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


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



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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence Cloud

Share your Confluence Cloud experience for a chance to win $500!

Take our 5-minute survey to win a $500 Visa gift card! Are you currently using Confluence Cloud? We want to hear from you! Fill out this quick survey about your Confluence Cloud experience so we ...

293 views 5 14
Read article

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