Created
February 22, 2019 10:12
-
-
Save epishan/2cc28e1a592e7229b848ebf72886167b to your computer and use it in GitHub Desktop.
Gets list of users for given project Role for all projects in given project category
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.atlassian.jira.ComponentManager | |
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.security.roles.ProjectRoleManager | |
import com.atlassian.jira.component.ComponentAccessor | |
import com.atlassian.jira.project.ProjectCategory | |
ComponentManager componentManager = ComponentManager.getInstance() | |
ProjectManager projectManager = ComponentAccessor.getProjectManager() | |
ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager | |
// name of role here | |
ProjectRole devsRole = projectRoleManager.getProjectRole("Administrator") | |
ProjectCategory projectCat = projectManager.getProjectCategoryObjectByName("Logistics") | |
projectManager.getProjectObjects().each {Project project -> | |
if (project.getProjectCategory() == projectCat) { | |
ProjectRoleActors actors = projectRoleManager.getProjectRoleActors(devsRole, project) | |
log.warn "$project.key, $project.name, $project.lead, ${actors.getUsers()*.name}\n"; | |
// if there is only one member of the role or you only want the first you could do: | |
//log.debug actors.getUsers().toList()?.first()?.name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment