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 vote
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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

184 views 1 11
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