Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Link to github sources

...

To use this script to automatically deactivate users:

  • Checkout the script from the github repository to $JIRAHOME/scripts:

    Code Block
    cd $JIRAHOME/scripts
    git clone https://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':


    (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)

...

Here is Postgres-flavoured SQL, creating a queries.inactive_users view, of users that can be deactivated (source at https://github.com/redradishtech/jira-user-deactivator-groovy/blob/master/active_users.sql):

Include Code
languagesql
urlhttps://raw.githubusercontent.com/redradishtech/jira-user-deactivator-groovy/master/inactive_users.sql

Here is a corresponding Groovy script that reads usernames from the view, and deactivates those accounts (source):

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

...

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

...

I haven't researched this much further, as instances I work with all have ScriptRunner available.

What about Confluence?

There is now a Confluence version of the inactive_users  SQL at https://github.com/redradishtech/jira-user-deactivator-groovy/blob/master/inactive_users_confluence.sql. Note that the SQL doesn't limit itself to Internal directories yet. I haven't made a Groovy deactivation script based around it yet.

Conclusion

Using ScriptRunner, we have implemented a means for Jira to automatically deactivate inactive users, thus saving license slots. This is (to my knowledge, as of  ) the only implementation that handles never-logged-in users. Users who require more flexibility can use the SQL-augmented approach.

...