Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Use Scriptrunner to add multiple groups to a single user


I am new to Scriptrunner and I want to speed up the onboarding process by building some "persona" style scripts. For example,

User - "Project manager" requires "jira-user", "jira-software", "customer-share" groups

(I usually have 20-30 groups to add)

Is there a script I could use to run to add this in?



2 answers

0 votes

I think you can pretty much copy and paste the script over at - swapping the line at the end from removeUserFromGroup to addUserToGroup

0 votes

Hi @David Lee 

You would need to use group manager to do that. It is very simple script.

ComponentAccessor.groupManager.addUserToGroup(userToAdd, groupName)

I made a video and shared the script with some error handling in one of my video here.



Thanks @Ravi Sagar _Sparxsys_ for the information, I am able to add single groups without error with this script.


What would I need to do to this to add in another group? Or do I just need to run it multiple times, changing the "group1" each time?
import com.atlassian.jira.component.ComponentAccessor
def userName = "User"
def groupNametoAdd = "group1"
def userToAdd = ComponentAccessor.getUserManager().getUserByName(userName)
def groupName = ComponentAccessor.getGroupManager().getGroup(groupNametoAdd)

ComponentAccessor.groupManager.addUserToGroup(userToAdd, groupName)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Confluence

An update on Confluence Cloud customer feedback – June 2022

Hi everyone, We’re always looking at how to improve Confluence and customer feedback plays an important role in making sure we're investing in the areas that will bring the most value to the most c...

333 views 2 7
Read article

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