Groups in roles

Hi All,

we seek all the groups in our JIRA which are applied in roles.

Is there a jelly script which gets the list of these particular groups with their roles?

Thanks in advance,

Rumi

1 answer

Hi,

I have this script to do some reporting based on project roles. May be it helps with some modifications for you.

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.bc.projectroles.ProjectRoleService
import com.atlassian.jira.util.SimpleErrorCollection
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.actor.GroupRoleActorFactory
import com.atlassian.jira.security.roles.actor.UserRoleActorFactory
import org.apache.log4j.Category
import org.apache.log4j.Logger
import org.apache.log4j.Level

log = Logger.getLogger("com.onresolve.jira.groovy.CheckPermissions")
log.setLevel(Level.DEBUG)

remoteUser = ComponentManager.getInstance().getJiraAuthenticationContext().getLoggedInUser()
log.debug ComponentAccessor.getProjectManager().getProjectObjects().size()
ComponentAccessor.getProjectManager().getProjectObjects().each { srcProject ->
    ProjectRoleService projectRoleService = (ProjectRoleService) ComponentManager.getComponentInstanceOfType(ProjectRoleService.class);

    SimpleErrorCollection errorCollection = new SimpleErrorCollection();

    projectRoleService.getProjectRoles(remoteUser, errorCollection).each {ProjectRole projectRole ->
        // Collection newProjectRoleActors = new ArrayList()
        log.debug (projectRole.name + ": " + projectRole.getId())
        ProjectRoleActors projectRoleActors = projectRoleService.getProjectRoleActors(remoteUser, projectRole, srcProject, errorCollection)

        // Copy users and groups, separately
        [UserRoleActorFactory.TYPE, GroupRoleActorFactory.TYPE].each {String actorFactoryType ->
            Collection newProjectRoleActors = new ArrayList()
            projectRoleActors.getRoleActorsByType(actorFactoryType).each {
                log.debug it.parameter
            }            
        }
    }
}

Regards,

Vijay

Yup, Groovy, not Jelly, but it does the job (I just posted something similar, but yours is better)

Hi Vijay,

it doesn't work. It lists a plenty of projects that doesn't use roles.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

790 views 2 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