How to use the Groovy Script Runner to create user.

Hello team

I would like to use groovy script runner to "create user" and "add User to Group". Please tell me how to write groovy script "create users" and "add user to group".

Do you have any sample groovy script? Thanks.

2 answers

1 accepted

Code for creating a user

ComponentAccessor.getUserUtil().createUserNoNotification(username, "",
emailAddress, displayName, null);

And for adding user to group you can use com.atlassian.jira.user.util.UserUtil.addUserToGroup(Group, User)

Georgiev-san Thank you very much for your information.


Code for creating a user -> I succeeded.

>import com.atlassian.jira.component.ComponentAccessor

>def userUtil = ComponentAccessor.getUserUtil()

>userUtil.createUserNoNotification("TEST MAN1111","","","TEST MAN1")


I try to use UserUtil.addUserToGroup of JIRA api but adding user to group failed.

>import com.atlassian.jira.component.ComponentAccessor

>def userUtil = ComponentAccessor.getUserUtil()

>userUtil.addUserToGroup("gr_Admin","TEST MAN1111")



>No signature of method: com.atlassian.jira.user.util.UserUtilImpl.addUserToGroup() is

>applicable for argument types: (java.lang.String, java.lang.String)

>values: [gr_Admin, TEST MAN1111] Possible

>solutions: addUserToGroup(com.atlassian.crowd.embedded.api.Group, com.atlassian.crowd.embedded.api.User),

>addUserToGroups(java.util.Collection, com.atlassian.crowd.embedded.api.User)


I am sorry to cause you inconvenience, but I am looking forward to your reply.

Best Regards,


Hi Hattori-san,

here's the full code for adding user to group

import com.atlassian.jira.component.ComponentAccessor;
def uu = ComponentAccessor.getUserUtil()
def user = uu.getUserByName("boris.georgiev")
def group = uu.getGroupObject("jira-developers")
uu.addUserToGroup(group, user.getDirectoryUser())


Thank you very much.

It was able to be settled!!

Best Regards, Takashi

Would you please mark the answer as accepted ? Thanks

Hi Boris,

would it be possible to extend this script to create multiple new users, each one with multiple group memberships?

I am looking to replace an older Jelly script which will probably not work from JIRA 7 upwards.

Thanks in advance



I am sorry for the delay in my reply.

Yes,Thank you very much. I was able to handle it.

Best Regards,


Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,264 views 14 20
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot