How can I find all JIRA users without any group assignments?

Darryl Lee August 20, 2013

Can anybody think of a way to find all JIRA users that do not belong to any group?

MySQL query would be fine - I just need userIDs. Somebody who worked here before thought that removing all group permissions was sufficient to keep a user "active", but we're finding that unless a user has Assignable and Create Issue (?) permissions, Bulk Changes are getting hung up on these "zombie" users.

My plan, once I get the list, is to use the JIRA CLI to assign these users to an "Ex-employees" group that only has the above permissions.

Thanks!

2 answers

1 accepted

5 votes
Answer accepted
Henning Tietgens
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.
August 20, 2013

You can use the Script Runner plugin and the following script:

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

UserUtil userUtil = ComponentAccessor.getUserUtil()

result = ''

userUtil.getUsers().findAll{userUtil.getGroupsForUser(it.getName()).size() == 0}.each{ u ->
    result += u.name + "<br>"
}

result

Henning

 

Darryl Lee August 20, 2013

Thanks Henning, this worked like a charm!

Daniela Razo May 18, 2018

.

Deleted user August 21, 2018

I use the suggested Scriptrunner script and get this error:

startup failed: Script20.groovy: 8: expecting '}', found '-' @ line 8, column 90. tName()).size() == 0}.each{ u -&gt; ^ 1 error

I'm not sure why I'm getting an error about the curly bracket "}" at that point. I copied and pasted this script directly into the Scriptrunner script console and ran it.

Henning Tietgens
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.
August 21, 2018

Hi, it's a HTML conversion error from Atlassian Answers to Atlassian Community. I corrected the script, please try to copy it again.

Henning

Deleted user August 21, 2018

Happy Days are Here Again. Thanks a lot!!

5 votes
Norman Abramovitz
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.
August 20, 2013

I believe this is close to what you are looking for.

SELECT U.ID, U.user_name, G.group_name
FROM cwd_user U
LEFT JOIN cwd_membership M ON U.ID = M.child_id
LEFT JOIN cwd_group G ON G.ID = M.parent_id
WHERE M.child_id IS NULL

Darryl Lee August 20, 2013

Thanks for the answer Norman, but it was easier for me to just run it from Script Runner.

Jonas Andersson
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.
December 14, 2016

Thanks man, exactly what i was looking for.

Suggest an answer

Log in or Sign up to answer