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
Hi Roberto,
Please find the solution at https://community.atlassian.com/t5/Answers-Developer-Questions/How-to-list-all-members-of-a-certain-project-role/qaq-p/528122
Cheers
Bhushan
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Project project = currentIssue.getProjectObject()
def projectRoleList = projectRoleManager.getProjectRoles().findAll {
it.getName() == "Administrators"
}
log.warn("projectRole: ${projectRoleList}================>>>>>>")
if (projectRoleList.size() == 0) {
return adminUserEmailList
}
def projectRoleActors = projectRoleManager.getProjectRoleActors(projectRoleList[0], project)
log.warn("projectRoleActors: ${projectRoleActors}")
def users = projectRoleActors.getUsers().toList()
users.each { adminUserEmailList.add(it.emailAddress) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.