How can i add Escalation service in script runner to perform this job daily as mentioned in the link: https://www.adaptavist.com/doco/display/SFJ/Automatically+deactivate+inactive+JIRA+users
I mean what should be the contents for:
JQL Query:
Userkey:
cron expression:
additional issue action:
Escalation service takes a JQL function and does something for each issue.
The page you found there is wrong - it does not relate to escalation service. You can run it in the script console or as a service.
Well now the Page is updated. I don't think its because of my Query or is it?
Well I tried what is now mentioned to run the script as a service. But before i run the actual script I tried a basic one to deactivate user from a group.:
import com.atlassian.crowd.embedded.api.User
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.util.UserManager
import org.apache.log4j.Level
import org.apache.log4j.Logger
Logger log = log
log.setLevel(Level.INFO)
UserManager userManager = ComponentAccessor.getUserManager()
UserService userService = ComponentAccessor.getComponent(UserService.class)
User updateUser
UserService.UpdateUserValidationResult updateUserValidationResult
def errors = ''
ComponentAccessor.getUserUtil().getAllUsersInGroupNamesUnsorted(['jira-inactive-users']).each { user ->
updateUser = ImmutableUser.newUser(user).active(false).toUser()
updateUserValidationResult = userService.validateUpdateUser(updateUser)
if (updateUserValidationResult.isValid()) {
userService.updateUser(updateUserValidationResult)
} else {
errors += "Update of ${user.name} failed: ${updateUserValidationResult.getErrorCollection().getErrors().entrySet().join(',')}\n"
}
}
return errors
log.info "${report}"
It seems that the service is not running the above code. I have created xyz.groovy file for above code and placed it under jira_home/scripts directory. No logs can be seen in atlassian-jira.log files either.
Can you help me out here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry wrong code. Please refer below:
import com.atlassian.crowd.embedded.api.User
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.util.UserManager
import org.apache.log4j.Level
import org.apache.log4j.Logger
Logger log = log
log.setLevel(Level.INFO)
UserManager userManager = ComponentAccessor.getUserManager()
UserService userService = ComponentAccessor.getComponent(UserService.class)
User updateUser
UserService.UpdateUserValidationResult updateUserValidationResult
def errors = ''
def report = ''
ComponentAccessor.getUserUtil().getAllUsersInGroupNamesUnsorted(['jira-inactive-users']).each { user ->
updateUser = ImmutableUser.newUser(user).active(false).toUser()
updateUserValidationResult = userService.validateUpdateUser(updateUser)
report += "${user.name},"
if (updateUserValidationResult.isValid()) {
userService.updateUser(updateUserValidationResult)
} else {
errors += "Update of ${user.name} failed: ${updateUserValidationResult.getErrorCollection().getErrors().entrySet().join(',')}\n"
}
}
log.info "${report}"
return errors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> Well now the Page is updated
What page?
Refer to your code for what?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Following Page: https://www.adaptavist.com/doco/display/SFJ/Automatically+deactivate+inactive+JIRA+users
>Refer to your code for what?
It seems that the service is not running the above code. I have created xyz.groovy file for above code and placed it under jira_home/scripts/ directory. No logs can be seen in atlassian-jira.log files either.
Can you help me out here?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you set up a service for it? Did you read the link I posted: https://scriptrunner.adaptavist.com/latest/jira/services.html
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.