Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Use new ScriptRunner Jobs

...

Include Code
languagegroovy
urlhttps://raw.githubusercontent.com/redradishtech/jira-user-deactivator-groovy/master/deactivate-inactive-jira-users-nonsql.groovy

To put use this script into productionto automatically deactivate users:

  • Save Checkout the above script from the github repository to $JIRAHOME/scripts:
    Code Block
    cd $JIRAHOME/scripts
    git clone https:/
    deactivate_inactive_users.groovy. Make it owned by root but readable by group jira.
  • Go to the Scriptrunner Script Console and do a test run:
    Image Removed
  • Warning

    I am finding that users are not actually deactivated, when the script is run like this as a service. The script runs successfully judging by the logs, but users are unaffected. YMMV - I have not yet debugged this, and it may affect only my Jira 8.5.1 instance.

    If all looks good, go to Jira's Services  admin page, and add a service of type com.onresolve.jira.groovy.GroovyService 
    Image Removed
    /github.com/redradishtech/jira-user-deactivator-groovy
    chgrp -R jira jira-user-deactivator-groovy    # Ensure Jira has read access.


  • If you first want to see what would  happen without deactivating anyone, edit deactivate-inactive-jira-users-nonsql.groovy  and comment out the updateUser line:

    Code Block
    // Comment out this line to do a dry run:
    // userService.updateUser(updateUserValidationResult)


  • Go to the ScriptRunner Jobs tab, e.g. by typing 'gg' then 'Script jobs':

    Image Added
    (ScriptRunner Jobs is just a nice UI around Jira Services. In the past one would have created a com.onresolve.jira.groovy.GroovyService Jira Service directly)
  • Create a *Custom Scheduled Job:

    Image Added
    For User pick an account with the Jira Administrators global permission. You might like to create a dedicated role account ('deactivator') as I have in the screenshot, so that the Job isn't tied to a user account, but this does cost a license slot.
  • Click Run Now to run the script interactively.
    Image Added
    The Logs  tab will show what actions the script took (or would have taken if you commented out updateUser):
    Image Added
  • If all looks good, click Add to permanently add the Job.

ScriptRunner Solution with SQL Rules

...

The script should be installed in $JIRAHOME/scripts/jira-user-deactivator-groovy/deactivate_inactive_users.groovy and invoked automatically as a service, as described above.

...

Without any plugins, the cleanest solution would be a script utilitizing utilizing Jira's REST interface. The script would search for inactive users with Crowd CQL, then deactivate them. A REST solution would have the advantage of also working on Cloud Jira.

...