Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get all Bitbucket users in Bitbucket Server

Daniel Burke February 1, 2018

Hi All,

I'm trying to retrieve all users from Bitbucket with this code: 

import com.atlassian.bitbucket.*;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.bitbucket.user.UserService;
import com.atlassian.bitbucket.user.Person
import com.atlassian.sal.api.component.ComponentLocator;
import com.atlassian.bitbucket.user.UserAdminService



final UserService userService = ComponentLocator.getComponent(UserService.class);

//File to be written to, can be CSV or TXT
File file = new File("/local/home/rbadmin_app2/output.txt")


ApplicationUser bitbucketUser = userService.getUserByName("");

for(int i = 0; i <= 100; i++){
log.error bitbucketUser
}

this currently returns nothing. 

Does anybody know where I'm going wrong? 

1 answer

0 votes
Anton Shaleev
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 2, 2018

Hi Daniel

Thank you for the question. According to Bitbucket Server API getUserByName has a mandatory variable username so it returns users matching usernames from the specified set if any. For empty set the empty result is correct.

I believe in order to find all active users you need to use 
@Nonnull public Page<ApplicationUser> findUsers (PageRequest pageRequest).

 

I am not expert in Java API so that I appreciate if anybody can confirm or correct me.

 

Anton

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events