Get group members in JIRA

Rumceisz
Contributor
May 1, 2012

Hi All,

I'd like to ask for you help. We need to add 100+ members from more groups to another group. But in the Edit members section we cannot export the members list (I mean simply a Copy (CTRL+C). Do you know a Groovy runner script I can list all the members with, what I can copy then?

Thanks in advance!

Rumi

4 answers

1 accepted

3 votes
Answer accepted
JamieA
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 1, 2012
import com.atlassian.jira.ComponentManager

def componentManager = ComponentManager.instance
componentManager.getUserUtil().getGroup("jira-users").getUsers()

Rumceisz
Contributor
May 1, 2012

Hi Jamie,

it works!

Thank you

Raam S January 29, 2018

Hi Jamie,

from the above code, how to give the customized group names instead hard coded "jira-users"

Sai Patnala November 11, 2020

Does this work if the group has more than 50 users?

The REST API only allows 50 users at a time. Wondering if that is true with getUsers method as well.

2 votes
Vladimir Korobov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 20, 2013

It works for me:

import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor

def userManager = ComponentAccessor.getUserManager()
def groupManager = ComponentAccessor.getGroupManager()
def group = userManager.getGroup("jira-users")
Collection<User> usersInGroup = groupManager.getUsersInGroup(group)
for (User user : usersInGroup){
	//
}

Rumceisz
Contributor
July 23, 2015

It doesn't work.

subitoag
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 27, 2015

Why? I just had to add the typecast: Collection<User> userList = (Collection<User>) groupManager.getUsersInGroup(group)

0 votes
glcn91 April 16, 2016

Hi,

 

I have a question. I want to write group membership write user picker custom field. When I create issue, group picker custom field set group name (A,B,C etc.) . I want to write that group picker custom field value's (Group A or B,C etc. membership)  another multi user picker custom field. It is possible ?

JamieA
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.
April 16, 2016

If I understand you. You want to get all the users from the groups in the first CF, then update a user CF with them? Yes you can do that, just get the user objects from groups, then set the multi user CF to that value.

glcn91 April 17, 2016

Hi Jamie,

Firstly , when issue create A Custom Field (Type=Group Custom Field) set group name. (X,Y,Z etc.) Then i want to  according to A Custom Field group value (X,Y,Z etc.)  write groups membership other custom field (multi user picer)

0 votes
Jeff Underwood August 24, 2012

Do you have something like this for Python?

Suggest an answer

Log in or Sign up to answer