List of users with the last time a Jira server user was active

Chris Shepherd March 22, 2023

We have an instance of Jira that has been in use for over 20 years,  and as you can imagine over that time it has collected a lot of user accounts.  I need to tidy these up but it seems a lot of our users never log in, preferring to mail in to jira.

Consequently, most user management tools don't help us as they only show the last login time.

 

Does anyone have a script that will list users with the last time they added a comment or created an issue?  or is this just too hard to get out of Jira ?

1 answer

0 votes
Robert Bailey
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.
March 22, 2023

Hi Chris, 

 

To clarify your issue, management tools show that the user has logged in if they mail to Jira? If you run the following script in the console, could you let me know if it picks up the accounts you would assume, or do they not show also?

If you want to read around where this script is from, I reference it from here: https://community.atlassian.com/t5/Jira-Software-questions/To-extract-all-JIRA-users-and-their-last-access-date/qaq-p/1613347

import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager



def userManager = ComponentAccessor.getUserManager()
def loginManager = ComponentAccessor.getComponent(LoginManager)

 

ArrayList oldUsers = new ArrayList()
Date today = new Date()
//CHANGE TO DESIRED AMOUNT
int threshold = 150

 

userManager.allApplicationUsers.toList().each { user ->
    def loginfo = loginManager.getLoginInfo(user.username)

 

    if (loginfo.getLastLoginTime() == null) {
        oldUsers.add(user.displayName)
    }
    else {
        def lastLogOn = new Date(loginfo.getLastLoginTime())
        def difference = today.minus(lastLogOn)
       
        if (difference >= threshold) {
            oldUsers.add(user.displayName)
        }
    }
 }

 

return oldUsers

Thanks, 

Bobby
Chris Shepherd April 4, 2023

Thanks Bobby,

last logged in time is really unreliable for us,  we have users who are allocated tasks but never log in.  In the end I wrote a c# program that took a list of users generated by Microoscope and issued the following 3 JQLs against each one:

$"issuekey in updatedBy(\"{userId}\", -90d) ORDER BY updated DESC";
$"assignee = \"{userId}\" AND assignee changed after startOfYear() ORDER BY updated DESC";
$"reporter = \"{userId}\" ORDER BY updated DESC";
then took the updated date for the first record returned from each one and droped them into a spreadsheet.  We could then use that to decide who to deactivete.

thanks
Chris

Suggest an answer

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

Atlassian Community Events