Skip to main content
Skip table of contents

Automated saving of unnecessarily used Jira licences

UDC allows you to track users who never logged in or haven't logged in for a specified number of days and you can use Jira Automation Rules to automate their deactivation. In this guide, you'll learn how to set up and utilize this functionality effectively.

  1. Go to Automation Rules, click Create rule

  2. Add a Scheduled trigger, (Example: with fixed rate of every: 1 days)

  3. Create action Create Variable: Create a variable named lastLoginBefore with value of:

Users never logged in

-1 if you want to clean up users who never logged in

Users who haven’t logged in for days

{{#now}}func=minusDays(<number_of_days>), format="toMillis"{{/}} if you want to clean up users who haven’t logged in for <number_of_days> days

last_login_before.png

  1. Create action Send Web Request: Send a REST API to get the list of users who you want to deactivate

    1. Url: GET <your_base_url>/rest/udcj/1.0/jira/user/filter?excludeCleanedUsers=true&lastLoginBefore={{lastLoginBefore}}&includeActive=true&includeInactive=true

    2. Headers:

      1. Authorization: Basic <your_token>

    3. Check Delay execution of subsequent rule actions until we've received a response for this webhook

get_cleaned_users.png

  1. Create action Create Variable: Create a variable named usernames to save the response and map them into a list of user keys

  2. Create action Send Web Request: Send a REST API to trigger bulk clean up

    1. Url: POST <your_base_url>/rest/udcj/1.0/cleanup/bulk

    2. Headers:

      1. Authorization: Basic <your_token>

      2. Accept: application/json

      3. Webhook body: Custom data

JSON
{
  "usernames": {{usernames}},
  "ruleId": <your_rule_id_to_deactivate_users>,
  "phase": <clean_phase>,
  "substitute": <substituter_username>
}

Example:

JSON
{
  "usernames": {{usernames}},
  "ruleId": 3,
  "phase": "PHASE_ONE",
  "substitute": "admin"
}
trigger_bulk_clean.png

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.