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?
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
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.