Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Use Scriptrunner to add user to group

I'm searching for a solution that gives me an opportunity to add the user from Custom Field to specific JIRA Group by a post-function workflow or a listener.

I saw solutions like the following example in the community, but this does not seem to work anymore; the addUserToGroup method is not recognized.


import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()

def user = "Neuling"

def group = groupManager.getGroup("Group1")



Thanks in advance!






2 answers

1 accepted

0 votes
Answer accepted

Hi @Sngy ,

Kindly check this link for script to remove users from group


Replace "removeUserFromGroup" with "addUserToGroup" and "userToRemove" with "userToAdd". It should work

Hi @Niranjan ,

it works now, thank you a lot!

This might help....


import com.atlassian.jira.component.ComponentAccessor

def userUtil = ComponentAccessor.userUtil
def userManager = ComponentAccessor.userManager
final String groupName = "GROUPA" // the group you want to add users
def group = ComponentAccessor.groupManager.getGroup(groupName) // user names of the users to add
final List<String> userToAdd = ["USR1", "USR2", "USR3"]

userToAdd.each {
def usertoadd = userManager.getUserByName(it)
if (!usertoadd) {
log.warn("User: $userToAdd doesn't exist")


if (ComponentAccessor.getGroupManager().getGroupsForUser(usertoadd).contains(group)) {
log.warn("User: $usertoadd.username already in the group: $groupName")


if(!group) {
log.warn("Group: $groupName doesn't exist")

} else {

userUtil.addUserToGroup(group, usertoadd)
log.warn("User: $usertoadd.username added to the $groupName")



Hello Vijay,

I want to check if the "Jira-users" group is used in the notification scheme or not.

If yes then send an email.

Can you please help me in that

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you