Blogs
Jira Jira Enterprise

How to Use Script Runner in Jira Cloud

Vabro icon

Vabro

date icon Date added icon

December 13, 2023

reading time icon Clock icon

3 min read

Blog Image

How to Use Script Runner in Jira Cloud

ScriptRunner is a powerful app for Jira Cloud that enhances customization and automation capabilities by allowing users to write scripts in Groovy to perform actions or retrieve data. It’s ideal for automating workflows, creating custom fields, or extending Jira's functionality. Here’s a step-by-step guide to using ScriptRunner in Jira Cloud.

Steps to Use ScriptRunner in Jira Cloud

1. Install ScriptRunner

Before using ScriptRunner, you must install it from the Atlassian Marketplace.

  • Go to Settings > Apps in your Jira Cloud instance.
  • Click Find new apps and search for ScriptRunner for Jira Cloud.
  • Click Install and follow the prompts.

2. Access ScriptRunner Features

Once installed, ScriptRunner can be accessed under Apps in the main Jira menu. Key features include:

  • Script Console: Run and test scripts manually.
  • Listeners: Trigger actions based on specific Jira events.
  • Post Functions: Add custom automation to workflows.
  • Built-In Scripts: Use pre-written scripts for common tasks.

3. Run Built-In Scripts

ScriptRunner offers pre-defined scripts to handle common automation and customization needs.

  • Navigate to Apps > ScriptRunner > Built-In Scripts.
  • Select a script, such as Copy Issue or Create Subtask.
  • Configure the script parameters (e.g., choose the project, issue type, or fields to modify).
  • Execute the script and verify the results.

4. Create Custom Scripts

If built-in scripts don’t meet your needs, you can write custom Groovy scripts.

  • Go to Apps > ScriptRunner > Script Console.
  • Write your Groovy script in the editor.
  • Use the Preview option to check for errors.
  • Click Run to execute the script.

Example Script: Automatically assign a ticket to the project lead when created

import com.atlassian.jira.component.ComponentAccessor  

def issue = Component Accessor.issue Manager.get Issue By Key("PROJECT-123")  

def projectLead = ComponentAccessor.projectManager.getProjectObj(issue.projectId).projectLead  

issue.assignee = project lead  

ComponentAccessor.issue Manager.update Issue(null, issue, com.atlassian.jira.event.type.EventDispatchOption.ISSUE_UPDATED, false)  

5. Set Up Listeners

Listeners allow you to automate actions when specific events occur in Jira (e.g., issue creation, status changes).

  • Navigate to Apps > ScriptRunner > Listeners.
  • Click Create Listener.
  • Choose an event (e.g., Issue Created, Issue Updated).
  • Attach a script or use a built-in listener action.
  • Save and test the listener.

6. Add Post Functions to Workflows

Post Functions in ScriptRunner let you execute scripts as part of Jira workflows.

  • Go to Project Settings > Workflows.
  • Edit the workflow and select a transition.
  • Add a Post Function and select ScriptRunner.
  • Choose a script or write a custom one to execute during the transition.

Benefits of Using ScriptRunner

  • Enhanced Automation: Simplifies repetitive tasks by automating them.
  • Custom Workflows: Create highly tailored workflows to meet specific needs.
  • Improved Reporting: Extract and manipulate Jira data using scripts.
  • Integration: Seamlessly integrates with other tools and APIs.

Why Vabro and Jira Together Are a Game Changer

While Jira is a robust project management tool, pairing it with Vabro takes your workflows to the next level. Vabro’s intuitive dashboards, customizable templates, and advanced automation tools complement Jira’s capabilities, making task management and reporting more seamless.

With Vabro, teams can integrate Jira effortlessly, enhancing visibility, collaboration, and efficiency. Choose Vabro for smarter, more efficient project management.

Get Started with Vabro

Get Started