You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I am trying to get all the administrators of the projects but I would like to get this in the table. There are several admins per project so I would like to make a table in which there would be several tables each covering the admins of each project
It is possible ?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.projectroles.ProjectRoleService;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.util.SimpleErrorCollection;
import com.atlassian.jira.user.util.Users
def sb = new StringBuffer()
ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class);
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
ProjectManager projectManager = ComponentAccessor.getProjectManager();
ProjectRole administrator = projectRoleManager.getProjectRole("Administrators");
ErrorCollection ec = new SimpleErrorCollection();
//get all projects
projectManager.getProjectObjects().each{
//get all project admins for that project
ProjectRoleActors existingActors = projectRoleService.getProjectRoleActors(administrator,it,ec);
if (existingActors != null){
//get list of user names
Set<Users> users = existingActors.getUsers();
users.each { user->
sb.append(user.getName() + ', ')
}
}
sb.append("\n")
}
return sb.toString()