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?

3 answers

1 accepted

This widget could not be displayed.

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

This widget could not be displayed.

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

This widget could not be displayed.

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

71 views 0 1
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