There is a standard way to check using a group in all permission schemes. But is there a way to check using a group in all projects' roles?
Try this Groovy script using script console
import com.atlassian.jira.bc.projectroles.ProjectRoleService; import com.atlassian.jira.component.ComponentAccessor; 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.security.roles.RoleActor; StringBuilder output = new StringBuilder(); ProjectManager projectManager = ComponentAccessor.getProjectManager(); ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class); ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class); final Collection<ProjectRole> projectRoles = projectRoleManager.getProjectRoles(); for(Project project : projectManager.getProjectObjects()) { for(ProjectRole projectRole: projectRoles) { final ProjectRoleActors projectRoleActors = projectRoleManager.getProjectRoleActors(projectRole, project); for (RoleActor actor : projectRoleActors.getRoleActors()) { if(actor.getDescriptor().equals("TheGroupNameYouLookingFor")){ output.append(project.getKey()).append(" : ").append(projectRole.getName()).append(" : ").append(actor.getDescriptor()).append("\n"); } } } } return output.toString();
Hi Ivan,
Currently, it is not possible to check a group has specific project roles in all projects. You can raise a new feature request for this at https://jira.atlassian.com and vote for it. In order to be implemented, it must meet certain levels according to our Implementation of new features policy.
Best Regards,
Steven
Hi Steven,
Thank you, I will.
BR,
Ivan
Hi Renjith,
Thank you very much!
I hope this ready feature will be added to the next JIRA version.
A workaround would be to find a user that is part of that role, go to the View Project Roles and then Edit Project Roles for User and it will show if a group is mapping that user to a project role and will name the group.
Hi @Renjith Pillai ,
Getting error as below (also in screenshot), while running in Scriptrunner Console
startup failed: Script991.groovy: 15: unexpected token: Collection @ line 15, column 7. final Collection<ProjectRole> projectRoles = projectRoleManager.getProjectRoles(); ^ 1 error
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script991.groovy: 15: unexpected token: Collection @ line 15, column 7. final Collection<ProjectRole> projectRoles = projectRoleManager.getProjectRoles(); ^ 1 error
Any thoughts ?
@Lokesh
Change de line as the image below
@Kalen Brown This workaround helped me. Thanks!
Can you guide me a solution to get projectId in "projectroleactor" table ?
if I debug to method bellow then I can see projectId but I can't get projectId.for (RoleActor actor : projectRoleActors.getRoleActors()) {
// something
}
Thanks.
It looks like you're new here. Sign in or register to get started.