Retrieve a users meta-data with Groovy

So far I have got a script which returns all of the users in my test instance of JIRA. 

I have also added to the script so that it is able to get all of the groups too.

However, this is quite basic and I would like to know how people use Groovy in order to retrieve more information (for example: Email, Fullname, login time, project roles and groups they're in etc).

I've been looking through the documentation but I'm feeling somewhat overwhelemed with the different classes and libraries to do different asks.

If anybody has any ideas, or could point my code in the right direction, that would be good.


My script:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.action.admin.roles.AbstractProjectRole
import com.atlassian.crowd.embedded.api.Group

def userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(true).includeInactive(true).maxResults(100000).build();

userSearchService.findUsers("", userSearchParams).each{ it->

def groupSearchService = ComponentAccessor.getComponent(GroupPickerSearchService);
def groupArray = groupSearchService.findGroups("")
def groupManager = ComponentAccessor.getGroupManager()

for(Group group in groupArray){
log.error group.getName().toString()

1 answer

0 vote
Tarun Sapra Community Champion Jan 09, 2018

You can use ComponentAccessor

def groupManger = ComponentAccessor.getGroupManager()

The for role you can use - ProjectRoleManager

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager.class) 

Group Manager has plenty of amazing methods to get deep insights into user group mapping., com.atlassian.jira.project.Project)


Each user is represented by "ApplicationUser" object which has methods like getEmailAddress() and getDisplayName()

Tarun Sapra Community Champion Jan 09, 2018

You can get currentUser using


Thank you very much!

Tarun Sapra Community Champion Jan 09, 2018

For login related info for the user you can use the "LoginManager"

You can fetch an instance of this class using "ComponentAccessor.getComponent(LoginManager.class)"

Thank you! Are you aware of how you can get the users that are in each project?

I currently am using:

def projectSearchService = ComponentAccessor.getProjectManager()
def projectArray = projectSearchService.getProjectObjects()

log.error projectArray + " " + projectRoles

This provides me with the project codes, and the available roles in my JIRA project, however I would like a list of the users in each role within the project. 

Tarun Sapra Community Champion Jan 10, 2018

Please see here

You will need to use ProjectRoleManager to get users for a specific role in a project.  So you can create a for loop which goes over the list of roles and for each ieration fetch ProjecctRoleActors and then do getUsers()

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,316 views 14 20
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