Script help

Spruha Shah October 12, 2023

Hi, 

I want to get a list of all active users with username and email address from a specific group in jira.  Trying to run this scirpt through script Runner console, any suggestions on how to get email address too? i pulled a list with just usernames.

1 answer

0 votes
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 12, 2023

Hi @Spruha Shah 

could you share your code? This would make it easier to analyze the problem.

How do you get the user names? do you only get a list of strings with the names or do you get a list of user objects?

Generally the user object has an email property and you can get this from a user object variable eg. ‚user‘ as follows:

user.getEmailAddress()

 

Best
Stefan

Spruha Shah October 18, 2023
import com.atlassian.jira.component.ComponentAccessor

 

def groupManager = ComponentAccessor.getGroupManager()
def user = User.getEmailAddress()

 

String groupName = "jira-software-users"

 

groupManager.getUsersInGroup(groupName)
user.getEmailAddress(user)
i am trying to get all users that are in 'jira-software-users' not just with username but also with email. 
In our jira, username and email are different for each user.
Stefan Salzl
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2023

groupManager.getUsersInGroup

Returns a collection of user objects of the users in the group. If you add a .getEmailAdress() it will return the email of all users.

The following script should do the work:

import com.atlassian.jira.component.ComponentAccessor

 

def groupManager = ComponentAccessor.getGroupManager()

 

String groupName = "jira-software-users"

 

groupManager.getUsersInGroup(groupName).getEmailAddress()
Best
Stefan

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events