Hello there,
I’m trying to extract all Jira users with with below details
user name, full name, email id, status and last login time stamp
Using JIRA Data center and script runner, below is my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def userManager = ComponentAccessor.getUserManager()
def users = userManager.getAllApplicationUsers()
def userList = users.collect {
[
userId: it.key,
fullName: it.displayName,
emailAddress: it.emailAddress,
active: it.active,
lastLoginMillis: it.lastLoginMillis
]
}
// Print the user list (you can modify this to export to Excel)
userList.each { user ->
def lastLogin = user.lastLoginMillis ? new Date(user.lastLoginMillis) : null
println("User ID: ${user.userId}, Full Name: ${user.fullName}, Email: ${user.emailAddress}, Active: ${user.active}, Last Login: ${lastLogin}")
}
However I get this error
No such property: lastLoginMillis for class: com.atlassian.jira.user ApplicationUser
I really appreciate your suggestion on how can I fix this
I am not sure if you have to use ScriptRunner. If not, then you can export all user accounts to an Excel spreadsheet like this:
It is created with a few clicks in Better Excel Exporter. You can install the app and export this data set using a trial license.
(Discl. it is a paid and supported app developed by our team. Free for 10 users.)
You can't, because there isn't such a property for ApplicationUser, much like the error suggests.
I'm more curious how you came to try getting it from the user object, as in, why.
Anyhoo, for that there is this interface:
With which you can #getLoginInfo(String username); and from LoginInfo you can then get the login related data.
Having said all of that, there is a kba from Atlassian for this: https://confluence.atlassian.com/jirakb/find-the-last-login-date-for-a-user-in-jira-server-363364638.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.