How to bulk get list of Jira Users having their user keys

I want to get list of Jira Users, preferably in one operation, by Jira Java API. I have list of corresponding User Keys. Most important restriction is that API must work both in Jira 6 and Jira 7.

1 answer

1 accepted

1 vote
Alexey Matveev Community Champion Jan 02, 2018


Try something like this

import com.atlassian.jira.component.ComponentAccessor


LoginManager loginManager = ComponentAccessor.getComponent(LoginManager.class);

Set<ApplicationUser> appUsers = ComponentAccessor.getUserManager().getAllUsers();

Thank you for your answer, however I would like to get only users that keys I have, in order to avoid situation of loading all Jira Users to obtain only fraction of them, e.g. 2000 of 20000.

Alexey Matveev Community Champion Jan 03, 2018

Filter the appUsers list as you wish. I do not think your Jira crashes if you get the full list first.

I will follow your advice. Last question: is there a way to get only active Jira Users?

Alexey Matveev Community Champion Jan 03, 2018

The problem is that you said you want a script for Jira 6 and Jira 7. In Jira 7 you can use UserSearchService which will let you filter users before retrieving them. I am not sure if UserSearchService will work for you Jira 6 version. That is why when you filter the appUsers list check if a user is active by isActive method of ApplicationUser class. If you want to try UserSearchService the code would look like that

import com.atlassian.jira.component.ComponentAccessor


import userSearchService = ComponentAccessor.getComponent(UserSearchService.class);UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(false).includeInactive(true).maxResults(100000).build();userSearchService.findUsers("", userSearchParams).each{ it-> log.error(it.getKey())}

But I am not sure if the code works for Jira 6.

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,314 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