How to find all projects where a group has a role?

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?

2 answers

1 accepted

6 votes
Renjith Pillai Community Champion Nov 10, 2013

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 Renjith,

Thank you very much!

I hope this ready feature will be added to the next JIRA version.

BR,

Ivan

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

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,169 views 13 19
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot