Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to get Bitbucket users from a JIRA Database

Is it possible, using Script Runner, to get all of the Bitbucket users, projects etc, that are synced with the JIRA Database?

Currently, all of my code returns null, I'm not if this is because of the JIRA Database and having no local users.


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
import com.atlassian.bitbucket.project.ProjectSupplier
import com.atlassian.bitbucket.util.PageRequest
import com.atlassian.bitbucket.project.ProjectService
import com.atlassian.bitbucket.util.PageRequestImpl

import com.atlassian.bitbucket.auth.AuthenticationContext
import java.util.*;
import org.apache.log4j.Level
import org.apache.log4j.Logger

def UserService userService = ComponentLocator.getComponent(UserService);

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

def ProjectService projectService
def PageRequest pageRequest = new PageRequestImpl(0, 100);
def projectName = projectService.findAll()
ApplicationUser bitbucketUser

def bitbucketU = userService.findUsersByName("", pageRequest)

log.debug( bitbucketU.getValues() )

//Collection<ApplicationUser> bitbucketUser = new ArrayList<ApplicationUser>();

// userService.getUserByName("");
for(int i = 0; i <= bitbucketUser.size(); i++ ){
file.append( "" + userService.getUserByName("").toString() )

for(Iterator<Collection> iterator = bitbucketUser.iterator(); iterator.hasNext();){
for(int i = 0; i <= projectName.size(); i ++){
log.error projectName
//file.append("" + projectName )

0 answers

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events