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.
Hello,
Try something like this
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Filter the appUsers list as you wish. I do not think your Jira crashes if you get the full list first.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I will follow your advice. Last question: is there a way to get only active Jira Users?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.jira.bc.user.search.UserSearchParamsdef 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.