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,551,752
Community Members
 
Community Events
184
Community Groups

How to get all users of JIRA with a Groovy script?

Hi,

I'm trying to put a script together to get a list of all users (cloud version), script/error below. Can anyone offer any guidance with this?

Thanks!

Mark

Script:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.util.UserUtil UserUtil userUtil = ComponentAccessor.getUserUtil() result = ” userUtil.getUsers().each{ u -> result += u.emailAddress } result
Error:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 2: unable to resolve class com.atlassian.jira.user.util.UserUtil
@ line 2, column 1.
import com.atlassian.jira.user.util.UserUtil
^

Script1.groovy: 1: unable to resolve class com.atlassian.jira.component.ComponentAccessor
@ line 1, column 1.
import com.atlassian.jira.component.ComponentAccessor
^

2 errors

at com.adaptavist.sr.cloud.workflow.AbstractScript.parseScript(AbstractScript.groovy:41)
at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:28)
at com.adaptavist.sr.cloud.workflow.AbstractScript$evaluate$1.callCurrent(Unknown Source)
at com.adaptavist.sr.cloud.events.ScriptExecution.run(ScriptExecution.groovy:26)
at ScriptExecution1_groovyProxy.run(Unknown Source)

 

 

4 answers

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil

UserUtil userUtil = ComponentAccessor.getUserUtil()

def result = ""

userUtil.getUsers().each{ u ->
result += u.username + "<br>"
}

result

Thank you very much.

1 vote
Gaston Valente
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.
Jul 11, 2017

Hi, this code is correct and works, but your version works too.

  • Which version of Jira are you using?
  • Are you running this from the script console?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil

UserUtil userUtil = ComponentAccessor.getUserUtil()

def result = ""

userUtil.getUsers().each{ u ->
result += u.emailAddress
}

result

Could this be modified to output users and number them so I can get a count of total users.

userUtil.getUsers() is deprecated, just saying

Is it possible to add last connexion date ?

I need the same... anyone who knows the answer?
Thanks...

Like Dave Liao likes this
0 votes
Stephen Hayden
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.
Sep 25, 2018

could this be modified to output users per project?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events