Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

141 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you