Hello,
I was working on adapting the existing Rename User script for JIRA 6.3 I got it working, to some extent, but something odd came up in doing some changes that explains a bug that we've had to workaround in the past:
gvs = gd.findByAnd("Membership", [childName: sourceUser, directoryId: 1, membershipType: "GROUP_USER"])
msg = "Update ${gvs.size()} Membership records"
log.debug(msg)
msgs << msg
if (!preview) {
List<GenericValue> targetGvs = gd.findByAnd("Membership", [childName: targetUser, directoryId: 1, membershipType: "GROUP_USER"])
List<Object> targetGroups = targetGvs*.get("parentName")
gvs.each {GenericValue gv ->
if (doMerge && targetGroups.contains (gv.get("parentName"))) {
gv.remove()
}
else {
gv.set("childName", targetUser)
gv.set("lowerChildName", targetUser)
gv.store()
}
}
}It's the segment that reassigns the groups in the script. It seems to only reassign the membership rows that have directoryId 1, and I'm not 100% sure why? I've finished adapting the script for JIRA 6.3 (with a few bugs, still, but it's functional, code is here) and I removed the directory mention, I'm just unsure whether i've broken something in the process?
Maybe it's to avoid bugs when merging users in different directories?
Thanks,
Eric