Scriptrunner script to merge user accounts?

Hi guys - we have noticed that over time users have had new accounts created when customer email their old email addresses and CC jira - as a result we might have two accounts for [old company name] and [new company name] but as a result, issues then end up assigned to the wrong user account

What I'd like to do is have a script that we can run periodically with a dump of user accounts line up then iteratively step through and change comments and reporter and assignee for the old accounts


I think there used to be a scriptrunner script to merge user accounts, but this doesn't seem to exist anymore

Any thoughts on whether there is a better way to do this?


1 answer

You mean this script

You have a number of options and none of them are great.  The simplest thing is to remove the groups from these legacy users, disable them and make sure they are removed from all Project Roles. Assuming you have your permission schemes set up to use Project Roles and Groups, they should no longer appear in user pickers.  That does nothing for the issues that have these legacy users in fields, though. You could use Bulk Edit to change them to the correct user, but that's messy. There isn't an easy way to change all the other possible things that could contain legacy users, like Watchers, Commenter, Attachee, Project Lead, etc. Hopefully that will be of some value.

Thanks @Dave Theodore [Coyote Creek Consulting]- that was exactly it, I'd be happy to hack something together, but wouldn't know where to start - especially with the changes to user management abstraction that have caught us out.  In my previous conversations with Atlassian, their best suggestion was to use a sed script with an XML dump, which arguably isn't too bad, but it would be nice if there was a built in method or a script which we can just build a truth table for.  

Heh. The last time I did the sed search & replace method was probably Jira 5.0 days and there were something like 28 different places that you had to search and replace for in an XML dump, while making sure your search is not overly broad and clobbering things you didn't intend to.  Honestly, I wouldn't go there. It was a mess to do this in those days and I can't imagine it's gotten a lot better. I'd socialize the method of disabling the old users first and see if that is good enough. It will save you a lot of headaches if that method will be acceptable. It's a decent amount of tedious work, but with clients that I've worked with, it's largely been good enough.

If you stand up a really old version of Jira and install the corresponding really old version of Script Runner, you can easily harvest the groovy script that did user merge. You could hack that and try to get it to update modern versions of Jira, but IMO, you're asking for a major headache in a best case scenario. Sorry, I can't remember the last version of Script Runner that had the script included.

Hi Dave - yeah, you're not wrong - I'd tried it out on staging, and it seemed to be successful (with the limited tests that I'd run) but it means a minimum of about 6 hours of downtime to edit, import then reindex


Mothballing the old accounts is the best option if we can't merge them, I'll run around it with a few key stakeholders, but I think it's probably worth investing some time in rewriting and updating the script if Jamie can make it available


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


251 views 0 6
Read article

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