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 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 yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

234 views 4 9
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