How to get groups, which are assigned to a specific role in a project?

I want to get the names of groups, which are assigned to a role in a project, but only found a way to get all usernames that are assigned to a role, with the following:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.user.ApplicationUser;

Collection<Project> projects = permissionManager.getProjects(new ProjectPermissionKey("BROWSE_PROJECTS"), appUser);
ProjectRoleManager projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
ProjectRole projectRole = projectRoleManager.getProjectRole("Role Name");

for(Project project : projects){
ProjectRoleActors projectRoleActors = projectRoleManager.getProjectRoleActors(projectRole, project);

 Is there any way to get the groupnames instead of all usernames?

1 answer

0 votes
Micky CARITTE Community Champion Jan 22, 2018


You might want to use the ProjectRoleManager.getProjectIdsContainingRoleActorByNameAndType() method, you can define which type of actor you want to get, in your case it would be ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE.

More details here:

Hope this helps!


Micky CARITTE Community Champion Jan 22, 2018

This is based on knowing the group name. If you don't want to check all groups individually, you might want to search for an alternative solution. Will keep you posted if I can find one!



thanks for this, but you already say it. It would be more comfortable if I get the groupnames directly by the project, instead of run through all groupnames individually and compare each projectId with the result list of the function.

Would be great if there is any solution! Otherwise I go on with this one...

Micky CARITTE Community Champion Jan 23, 2018

Sure! Please keep us posted if you find any better solution, very interesting question :)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

93 views 0 4
Read article

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