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
Hi Eric!
I see that your script contains the variable "directoryId:
1
" on multiple lines. Have you tried removing this or changing to the external directory's ID?
Also, please check your directories settings to see if JIRA has "Read/Write" permission or "Read-only with local groups".
--
Cheers!
Joao
Hi Joao, I'm not trying to troubleshoot a bug here. I'm not having any significant problems with my script. I was just asking why the script was written that way in the first place, as I didn't write it, it's a segment from the rename user script that Jamie Echlin wrote. Eric
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The example code you got is a bit old and it is using deprecated classes. That was the probably the way of achieving this in Jira 4/5, but I'm sure there is a better way to do it with the new managers and services provided in the newest Jira API versions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alejo, Again, that's completely beside the question that I'm asking here. I'm aware that the classes are deprecated. It wasn't written by me and hasn't been updated since jira5 (at least). I'm simply asking if there is a specific reason why only the internal directory is changed in the script, is it to avoid a bug/issue of which I'm still unaware? I've actually done some adjustments in the live code that I'm using in order to avoid the deprecated classes and methods, this is the original code from the plugin that I'm posting here as a reference. Eric
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.