Hello, in my old Jira Version it was possible to run this code for determine all Users there nerver was loged-in for the last 100 Days
//sind sicher zu viele muss mal aussortiert werdenimport com.atlassian.crowd.embedded.api.CrowdService import com.atlassian.crowd.embedded.api.UserWithAttributes import com.atlassian.crowd.embedded.impl.ImmutableUser import com.atlassian.jira.bc.user.UserService import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.user.ApplicationUser import com.atlassian.jira.user.ApplicationUsers import com.atlassian.jira.user.util.UserUtil import com.atlassian.jira.security.groups.GroupManager int numOfDays = 100 // Number of days the user was not logged inDate dateLimit = (new Date())- numOfDays UserUtil userUtil = ComponentAccessor.userUtil CrowdService crowdService = ComponentAccessor.crowdService UserService userService = ComponentAccessor.getComponent(UserService) ApplicationUser updateUser //UserService.UpdateUserValidationResult updateUserValidationResultGroupManager groupManager = ComponentAccessor.getGroupManager() // counters to count the number of users per outcomelong countAll = 0 long countDeactivated = 0 long countActivelyUsing = 0 long countNeverLoggedIn = 0 userUtil.getUsers().findAll{it.isActive()}.each { countAll++ // to keep track of all users we've looped through UserWithAttributes user = crowdService.getUserWithAttributes(it.getName()) if (groupManager.isUserInGroup(it.getName(),"gaa-jira-lohfeld")){ String lastLoginMillis = user.getValue('login.lastLoginMillis') if (lastLoginMillis?.isNumber()) { Date d = new Date(Long.parseLong(lastLoginMillis)) if (d.before(dateLimit)) { updateUser = ApplicationUsers.from(ImmutableUser.newUser(user).active(false).toUser()) } else { countActivelyUsing++ } // EndIF login date is longer then 150 days } else { countNeverLoggedIn++ //TODO: hier noch reinbringen dass nur user angezeiogtw erden die vor 100 Tagen angelegt wurden updateUser = ApplicationUsers.from(ImmutableUser.newUser(user).active(false).toUser()) String creationMillis = user.getValue('created') log.warn("Never Loged in ${updateUser.name}") } // EndIF login time is a number } // EndIF user is in one of the exempted groups} // Looped through last user log.warn("${countAll} active users checked in total.\n") log.warn("${countActivelyUsing} users who have logged in during last 100 days.\n") log.warn("${countNeverLoggedIn} users never logged in.\n")
since my last update to 9.4.4 the sript doesn’t rund and terminate with the error
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.user.util.UserUtilImpl.getUsers() is applicable for argument types: () values: [] Possible solutions: getClass(), every() at Script3.run(Script3.groovy:30)
What can i do, that the script is running again?
Yes this function is no longer available since JIRA 9.0.0. You could use
getUsersInGroupNames(Collection<String> groupNames) |
instead using
getUsersInGroupNames(["jira-software-users, jira-administrators"]) |
You can list the group that grant application access for instance.
Regards
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.