Scriptrunner script to merge user accounts?

Scott Harman
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 20, 2017

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?

Cheers

1 answer

1 vote
Dave Theodore [Coyote Creek Consulting]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2017

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.

Scott Harman
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2017

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.  

Dave Theodore [Coyote Creek Consulting]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2017

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.

Scott Harman
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 21, 2017

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

Cheers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events