Skip to content

Instantly share code, notes, and snippets.

@vikrantyadav11
Created May 2, 2021 05:57
Show Gist options
  • Select an option

  • Save vikrantyadav11/656383041bb95e5aad2158cb31694792 to your computer and use it in GitHub Desktop.

Select an option

Save vikrantyadav11/656383041bb95e5aad2158cb31694792 to your computer and use it in GitHub Desktop.
Add users to a jira group
import com.atlassian.jira.component.ComponentAccessor
// the group you want to remove users from
final String groupName = "jira-users"
// user names of the users to remove
final List<String> usersToRemove = ["john.doe","user_B"]
def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
def group = ComponentAccessor.groupManager.getGroup(groupName)
assert group : "Could not find group with name $groupName"
usersToRemove.each {
def userToAdd = userManager.getUserByName(it)
userUtil.addUserToGroup(group, userToAdd)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment