Hello guys,
Until recently we were on jira Server 8.22 and we were using this script in scriptunner console to copy user groups from A user to B user:
importcom.atlassian.jira.component.ComponentAccessorimportcom.atlassian.jira.security.roles.ProjectRoleActorimportcom.atlassian.jira.security.roles.ProjectRoleManagerimportcom.atlassian.jira.bc.projectroles.ProjectRoleServiceimportcom.atlassian.jira.security.GlobalPermissionManagerimportcom.atlassian.jira.security.Permissionsimportcom.atlassian.jira.user.util.UserUtilimportcom.atlassian.jira.util.SimpleErrorCollectionimportorg.apache.log4j.Categoryimportcom.atlassian.jira.project.Project;importjava.util.ArrayList;defuserManager = ComponentAccessor.getUserManager()defgroupManager = ComponentAccessor.getGroupManager()defgroups = groupManager.getGroupsForUser("A")// user à copier
defuu = ComponentAccessor.getUserUtil()defuser = uu.getUser("B")// user prenant la copiegroups.each{ group ->defgrplec = uu.getGroupObject(group.name)groupManager.addUserToGroup(user,grplec)}
The script was working just fine before upgrading to jira server 9.4.4Now we get this error:"Something went wrong: MissingMethodExceptionNo signature of method: com.atlassian.jira.user.util.UserUtilImpl.getUser() is applicable for argument types: (String) values: [B] Possible solutions: getAt(java.lang.String)"
Does anyone has a solution?
Hi, @Andra Marilena SANDULEASA
You're welcome :) Slightly optimized and refactored script.
/*
* Created 2023.
* @author Evgeniy Isaenkov
* @github https://github.com/Udjin79/SRUtils
*/
import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
UserManager userManager = ComponentAccessor.getUserManager()
GroupManager groupManager = ComponentAccessor.getGroupManager()
ApplicationUser userA = userManager.getUserByName("A") as ApplicationUser
ApplicationUser userB = userManager.getUserByName("B") as ApplicationUser
Collection<Group> groups = groupManager.getGroupsForUser(userA)
groups.each { Group group ->
groupManager.addUserToGroup(userB, group)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.