ScriptRunner - How to retrieve users in certain roles

Hello Community,

I am trying to figure out how to retrieve all the user in certain roles.

I am working on a script that will grab all the users associated with a certain role, in this case Project Administrator role, for all the projects in Jira and send them an email when a certain event is triggered.

I currently have everything completed except for fetching the users in the Project Administrator role. 

Would anyone know how one is to approach this?

Any help is greatly appreciated!

-Roberto

1 answer

hi @Bhushan Nagaraj,

i read the attached community post. I was able to retrieve all users from a specific role in every project in my Jira Instance.

I can’t seem to figure how to loop through them.

could you explain how I can fetch the users and loop through everyone.

i require the emails of every user and i am thinking I can do so by looping through all the users, getting their names, and passing that to UserManager.getUserByKey() and from there fetch the emails.

-Roberto

Hey Roberto,

Continuing from the example provided in the link.

ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(devsRole, project)
def users = actors.getUsers().toList()
users.each {
it.emailAddress
}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

125 views 4 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you