Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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
4,559,151
Community Members
 
Community Events
184
Community Groups

Use Scriptrunner to add multiple groups to a single user

Edited

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?

Thanks

David

2 answers

1 vote
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 16, 2022

I think you can pretty much copy and paste the script over at https://library.adaptavist.com/entity/remove-specified-users-from-a-group - swapping the line at the end from removeUserFromGroup to addUserToGroup

0 votes
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 16, 2022

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

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
TAGS
AUG Leaders

Atlassian Community Events