How to bulk rename username

I would like to use JIRA API to bulk rename usernames. I am currently using JIRA 6.3.14 and I am also having the Groovy Plugin installed. I am not able to find any API to help me achieve this. Can someone point me to the right direction. As we are maintaining a big user directory the use of Jira UI for manual update of the username is not an option


2 answers

1 accepted

I found a solution!

Using groovy

ImmutableUser.Builder builder = ImmutableUser.newUser(ApplicationUsers.toDirectoryUser(user));;
userManager.updateUser(new DelegatingApplicationUser(user.getKey(), builder.toUser()));


This may be a dumb question, but how do you use that groovy script?



import com.atlassian.jira.user.DelegatingApplicationUser
import com.atlassian.crowd.embedded.impl.ImmutableUser
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.util.UserManager;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
UserManager userManager = ComponentAccessor.getUserManager();
ApplicationUser appUser = userManager.getUserByKey("<old_username>");
ImmutableUser.Builder builder = ImmutableUser.newUser(ApplicationUsers.toDirectoryUser(appUser));"<new_username>");
userManager.updateUser(new DelegatingApplicationUser(appUser.getKey(), builder.toUser()));

Wouldnt it be great if you could export all users, then import them again having made global changes.

JIRA ADMINS - This has been wanted/needed for many years.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,981 views 12 18
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot