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,556,318
Community Members
 
Community Events
184
Community Groups

Scriptrunner bulk adding users to Group

I have about 100 users I would like to bulk adding them to a group, can I use Script Console in Scriptrunner? I'm new at scriptrunner, please advise.

Thanks,

John

1 answer

0 votes
Alejandro Suárez
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.
Feb 18, 2019

Hi @John Cliff Le , you could use this, this will add ALL your users to the selected group.

Use it carefully. You have to put this in the  ScriptRunner "Script Console"

import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.UserUtils

GroupManager groupManager = ComponentAccessor.getGroupManager()
Group group = groupManager.getGroup("My Group") //Change this with the name of your Group

UserUtils.getAllUsers().each {
ApplicationUser user ->
groupManager.addUserToGroup(user, group)
}

Check out the notes in the code to fit your needs.

Regards. 

Hi Alejandro,

Appreciate and thanks for responding!

I ran it and got some errors:

Request:

import com.atlassian.crowd.embedded.api.Group
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.UserUtils

GroupManager groupManager = ComponentAccessor.getGroupManager()
Group group = groupManager.getGroup("jiratestapi") //Change this with the name of your Group

UserUtils.getAllUsers().each {
ApplicationUser user ->
groupManager.addUserToGroup(user, group)
}

Responses:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 4: unable to resolve class com.atlassian.jira.user.ApplicationUser @ line 4, column 1. import com.atlassian.jira.user.ApplicationUser ^ Script1.groovy: 1: unable to resolve class com.atlassian.crowd.embedded.api.Group @ line 1, column 1. import com.atlassian.crowd.embedded.api.Group ^ Script1.groovy: 2: unable to resolve class com.atlassian.jira.component.ComponentAccessor @ line 2, column 1. import com.atlassian.jira.component.ComponentAccessor ^ Script1.groovy: 5: unable to resolve class com.atlassian.jira.user.UserUtils @ line 5, column 1. import com.atlassian.jira.user.UserUtils ^ Script1.groovy: 3: unable to resolve class com.atlassian.jira.security.groups.GroupManager @ line 3, column 1. import com.atlassian.jira.security.groups.GroupManager ^ 5 errors at com.adaptavist.sr.cloud.workflow.AbstractScript.parseScript(AbstractScript.groovy:51) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:32) at com.adaptavist.sr.cloud.workflow.AbstractScript$evaluate$4.callCurrent(Unknown Source) at com.adaptavist.sr.cloud.events.ScriptExecution.run(ScriptExecution.groovy:27) at ConsoleScriptExecution3_groovyProxy.run(Unknown Source)

Alejandro Suárez
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.
Feb 19, 2019

Hi @John Cliff Le , wich versión of Jira do you have?

We are on the cloud:

Jira: Cloud

Adaptavist version: 1.1.62-AC

Thanks,

John

Alejandro Suárez
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.
Feb 19, 2019

My bad, I dindt saw the tags, you cant use this in cloud. Let me check the viability of doing this in cloud.

No worries, thanks!

Am also looking into the restapi/postman on different datasets.

Regards,

John

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events