I have a scenario where we have a JIRA instance (6.4.7). I have to do some user management clean up and I'm wanting to be able to run a script (ideally using Scriptrunner) to allow me to remove multiple users from a specified group..
Any help would be appreciated
Hiya Darren!
You should be able to do something like this:
import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.groupManager
def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
def usersToRemove = ["exampleUser1","exampleUser2","exampleUser3","exampleUser4","exampleUser5"] //User Names
def groupToAlter = groupManager.getGroup("NameOfGroup")
usersToRemove.each{
def currentUser = userManager.getUserByName(it)
userUtil.removeUserFromGroup(groupToAlter, currentUser)
}
Take this script, fill in the user names, fill in the name of the group, and then run it in the Script Console!
Is this close to what you were looking for? :D
Aidan
Hi @Aidan Derossett [Adaptavist] tried your script in Jira 6.4.13 in script console, getting error :
No signature of method: com.atlassian.jira.user.util.UserUtilImpl.removeUserFromGroup() is applicable for argument types: (com.atlassian.crowd.embedded.impl.ImmutableGroup, com.atlassian.jira.user.DelegatingApplicationUser)
Pls suggest
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That script is for Jira 7+
Jira 6 has different user objects, you'll need to convert it to use applicationuser objects I think.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Will this script work for JIRA data center. I executed the script with two users and license count has reduced by 200. How will the script work for groups that has sub-groups? Thanks
Niran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jira is not aware of sub-groups, it just sees one single list of users in a group. I suspect it will fail for members of sub-groups.
But, yes, it should work fine for data centre.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Nic,
Would this script be able to remove from multiple users in Crowd 2 groups each?
if users on list have let's say jira and confluence to be removed?
Is there a specific API or console to run the script in ?
much thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes it can do that if you tweak it a bit to aim at the groups.
It is a Scriptrunner script, so Aiden built it to be run in the SR console
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Aidan Derossett [Adaptavist]
I would like knwo if i can insert the login in the "@ShortTextInput"
and he display me the groups attached to this user and i can the delete this user for all groups he attached
Example
Login : test12
test12 attchdes groups : group1-user ; group2-dveelopers
Delete the users test 12 so that it us not part of the groups that are displayed
i have started the script but i'm blocked
Thanks in advance
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.