Hi all can anyone please help me with the script for getting the list of users in jira Name, Email Address, and active and in active users list and created , last updated date in a single script? is that possible to get all these details in a single script? please help me in this thank you in advance
Run below Script in Script console.
in Status column :- False means inactive user and true means active user.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
import java.text.SimpleDateFormat;
import java.util.Date;
import com.atlassian.jira.user.util.UserUtil
UserUtil userUtil = ComponentAccessor.getUserUtil()
def loginManager = ComponentAccessor.getComponentOfType(LoginManager.class)
def users=ComponentAccessor.getUserUtil().getUsers()
StringBuilder builder=new StringBuilder()
builder.append("<table border = 1><tr><td><b>User Name</b></td><td><b>Full Name</b></td><td><b>eMail Address</b></td><td><b>Last Login</b></td><td><b>Status</b></td><td><b>Group</b></td></tr>")
users.each{
Long lastLoginTime = loginManager.getLoginInfo(it.username).getLastLoginTime()
String activeStatus=it.active
if(activeStatus=="false")
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>Inactive User</td><td>"+it.active+"</td></tr>")
else if(lastLoginTime==null)
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>Logon not found</td><td>"+it.active+"</td></tr>")
else if(userUtil.getGroupsForUser(it.getName()).size() == 0)
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>No Group added</td><td>"+it.active+"</td></tr>")
else{
Date date=new Date(lastLoginTime);
SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy hh:mm");
String dateText = df2.format(date);
builder.append("<tr><td>"+it.username+"</td><td>"+it.displayName+"</td><td>"+it.emailAddress+"</td><td>"+dateText+"</td><td>"+it.active+"</td></tr>")
}
}
builder.append("</table>")
return builder
Hi @Vikrant Yadav its working now tnq soo much for the script ...and how can i get these details in confluence?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cool! Glad to hear it works for you.
For Confluence i am not sure, we dont have Script Runner installed in Confluence.
Start new Conversation in Atlassian Community for Confluence.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the script is not returning last logon for the active/true users also not returning groups the user belongs to.
Would be able to work on your query? as it is really good one... also want to find out how to automate this to run every 30days or 90days... as a scheduled job. that would be very much helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Vikrant Yadav same question but we need extract it into excel.
Actually while run this script in console we are getting below error.
Error
This resource requires WebSudo.
Please resolve my issue, Thank in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the latest error after running above script
groovy.lang.MissingPropertyException: No such property: username for class: com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser at Script73$_run_closure1.doCall(Script73.groovy:12) at Script73.run(Script73.groovy:11)
Please provide me the solution
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @govardhan reddy try this script :- https://gist.github.com/vikrantyadav11/b5697244994b3ce46e20831ed0ef43f4
run script in script console. You will get user data in email body and user details in csv file . It include last login, username , full name , email address, status false for inactive user.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Vikrant Yadav the above scipt getting these errors, the jira version is old 6.4.13, please suggest the script for these errors and let me know how to rectify.
Actually doesnt know the groovy script.
Thanks in advance..
2022-07-01 04:06:33,843 WARN [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingPropertyException: No such property: username for class: com.atlassian.jira.crowd.embedded.ofbiz.OfBizUser at Script3$_run_closure1$_closure4$_closure5$_closure6$_closure8.doCall(Script3.groovy:59) at Script3$_run_closure1$_closure4$_closure5$_closure6.doCall(Script3.groovy:58) at Script3$_run_closure1$_closure4$_closure5$_closure6.doCall(Script3.groovy) at Script3$_run_closure1$_closure4$_closure5.doCall(Script3.groovy:50) at Script3$_run_closure1$_closure4$_closure5.doCall(Script3.groovy) at Script3$_run_closure1$_closure4.doCall(Script3.groovy:49) at Script3$_run_closure1$_closure4.doCall(Script3.groovy) at Script3$_run_closure1.doCall(Script3.groovy:48) at Script3$_run_closure1.doCall(Script3.groovy) at Script3.run(Script3.groovy:27)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@govardhan reddy I have tested on my machine it’s working fine. Kindly try to update scriptrunner version
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.