I'm currently attempting to find all users in a group then add all of them to another group using scriptrunner. Below I am able to view the individuals in the initial group, but I am unable to add them to another. Below is currently what I have.
**edit** we are using crowd to manage our groups. These are not local groups.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.search.UserSearchService
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
def groupManager = ComponentAccessor.getGroupManager()
def userManager = ComponentAccessor.getUserManager()
def usersInGroup = groupManager.getUsersInGroup("GRC-RefSeq")
log.warn(usersInGroup)
def systems = groupManager.getGroup("Systems")
for(people in usersInGroup){
//lost
}
I've figured it out.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.Group
def groupManager = ComponentAccessor.getGroupManager()
def userManager = ComponentAccessor.getUserManager()
def usersInGroup1 = groupManager.getUsersInGroup("THIS IS GROUP 1")
def usersInGroup2 = groupManager.getUsersInGroup("THIS IS GROUP 2")
log.warn(usersInGroup1)
log.warn(usersInGroup2)
def systems = groupManager.getGroup("ADD TO THIS GROUP")
Collection<ApplicationUser> Group1 = usersInGroup1
Collection<ApplicationUser> Group2 = usersInGroup2
for (ApplicationUser Users1 : Group1){
groupManager.addUserToGroup(Users1,systems)
}
for (ApplicationUser User2 : Group2){
groupManager.addUserToGroup(User2,systems)
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.