3 min read

The Script Series, Volume 1: Automate your Administration with ScriptRunner for Jira

AD
Andra Dinu
Thu, 14 Feb 2019 ScriptRunner
The Script Series, Volume 1: Automate your Administration with ScriptRunner for Jira

The Script Series, Volume 1: Automate your Administration with ScriptRunner for Jira

Script collections in the Adaptavist Library

Collections are a group of scripts that have similar functionalities. We have put these together so you can easily find the scripts that may benefit you.

If you’re new around here, it’s time for a quick recap. Check out our other blog posts in The Script Series below to find out more:

 

  • Volume 2 featured our ‘Working with Dates and Times’ collection which lets you automate and extend your built-in Jira workflows.   
  • In Volume 3, we collaborated with our Partner, ALM Works, to help you utilise the power of ScriptRunner and Structure together. This collection provides ways to automate, extend and customise your structures in Jira. 
  • In Volume 4, we show you five simple scripts to automate issues in Jira.

First up, we will be exploring the collection ‘Getting started with Users and Groups in Jira’. One of the basic actions administrators have to take on a regular basis is keeping the Users and Groups in sync with the onboarding and offboarding of employees. This collection is to help you make bulk actions easy, such as updating all users in a group at once.

Jira user groups

Script 1 - Jira User Properties

User properties enables you to store data that’s specific to user/s, such as location, job role, or phone number. This script allows you to add multiple properties for multiple users with the same script; saving you the task of adding each item manually.

For example, this may be useful if you raise a support request in Jira as you can route the ticket to users who service that location in the issue workflow.

Script 2 - Remove Specified Users from a Group

There are two ways that you can use this script, either from the ScriptRunner Console as a single script, or as part of a larger script facilitating other features in ScriptRunner for Jira.

Perhaps you want to keep your instances clean and tidy? Use this script along side the ‘Deactivate Idle Users’ script, the inactive users will be shown and the ‘Remove Specified Users from a Group’ script will remove them from all the groups they’re part of.

Script 3 -  Validate the User Group of the Assignee

You may want to ensure that only members of a specific group can be can be added as an assignee. This validator script means you can set this up on any transition that you want this check to be enforced on.

Script 4 - Create a User in Jira

Use this script to create a new user in Jira. This snippet benefits you by including validation to check that the user hasn’t already been created. In addition, this script has the ability to collect and log errors for future reference.

Script 5 - Create a Group in Jira

In addition to creating users in Jira, it’s often necessary to create groups. For example, a group can be created when multiple users in your instance need the same permissions or restrictions. This script saves you from adding all the users to the group manually.

What’s Next?

Now you’ve made your administration in Jira easy, keep an eye out for the next post, spotlighting the ‘Working with Dates and Times’ collection and its most common use cases.

Haven’t tried out the Adaptavist Library yet?


Stay up to date by signing up for monthly Adaptanews