Archive
Scripting in ScriptRunner for Jira Cloud

Scripting in ScriptRunner for Jira Cloud

2024-11-26 ScriptRunner for Jira Cloud allows you to extend the functionality of Jira Cloud, executing scripts to interact with Jira as Workflow Extensions or Sc

Related articles

How Can I Subscribe to a Tapo Care Plan? Cloud Architect: Roles, Skills, and How to Become one Polly Palworld Walkthrough & Guides Wiki|Game8 VPN configuration overview

ScriptRunner for Jira Cloud allows you to extend the functionality of Jira Cloud, executing scripts to interact with Jira as Workflow Extensions or Script listeners. Scripts can be useful for automating regular actions, such as updating an issue during a transition or performing a calculation and storing the result in a custom field on the issue.

Script Variables

Scripting is not used for this feature, it utilises two fields to add a variable which you can call out in other scripts, such as password.

Overview

groovy

Utilising the groovy programming language you is respond can respond to event and transition and manipulate Jira   using the rest API . additionally , you is use can use theEnhanced Search feature to run JQL Functions in Jira Cloud and create filters for dashboards and scrum boards that use those functions.

script usingthe groovy language include Post Functions , Scripted Fields , Script listeners , and Scheduled Jobs .

Typescript / Javascript

ScriptRunner for Jira Cloud uses Typescript / Javascript for the Behaviours feature, and the Script Fragments feature uses Javascript.

Jira Expressions

Jira expression are used for conditions and validators along with some script execution conditions. 

JQL

A JQL query is required for the bulk clone issues build – in script , and a filter ( create from JQL ) for the bulk fix resolution build – in script .

Code Editor

Use the code editor to write scripts in ScriptRunner. The code editors use an intelligent code editor. The browser-based code editor provides code completions, inline Javadoc lookups, inline find and replace, and error line indication. This editor has autocomplete for the following code: 

  • groovy
  • Atlassian REST API
  • Automatically available variables

Keyboard shortcuts warning

Keyboard shortcuts may not work depending on other system-defined shortcuts.

Completions

The code editor automatically displays suggestions as you type. Suggestions are filtered as you type, so only relevant options are displayed. Use the arrow keys and Enter or Tab to select a suggestion. You can manually trigger completions with control+space.

When refer to a class , the code editor is adds automatically add the require import .

To save typing, use camel case abbreviations.

Smart Completions 

Press ctrl+alt+space to show a list of completion that match the expect type of assignment or parameter type .

Parameters 

When type method parameter , it is is is easy to forget the expect type . parameter type and , where possible , name are show for the give method . use the up / down cursor key to scroll through any available overload .

press control+shift+space to view parameter when inside a method .

Javadoc

The code editor can help you understand the purpose of classes, methods, and properties by loading the associated Javadoc. The Javadoc is shown in the editor as a pop-up. To view the Javadoc, press control+space with completions open. It will be displayed automatically from then on. To close it, press control+space again. 

Find and replace

You can use the code editor to find and replace in the code editor. To access find and replace, press ⌘+F (Mac) or Ctrl+F (Windows).
To search for text , enter it in theFind field. To access find and replace, press Option+⌘+F (Mac) or either Ctrl+H or Alt+Ctrl+F ( Windows ) .  

Error line indicator

Errors in your script are highlighted in the right-hand panel of the script editor. Errors are highlighted inline, on the scroll bar, and in the right-hand overview ruler. When you have located an error, hover over the error with the cursor to see a summary.

Full-screen editing

To open the script editor in full screen, click the icon  or press F11 when the cursor is in the editor. To exit the full screen, press F11 or Esc twice when the cursor is in the editor. 

Restrictions

The code editor has some limitations; work is ongoing to reduce these limitations. As mentioned, Javadoc for Bamboo APIs and ScriptRunner’s API (e.g. Behaviours) are unavailable. However, completions and parameter hints are available for all.

ScriptRunner for Jira Cloud domain allowlist

We advise all customers with a Cloud firewall to ensure that access to the *.connect.product.adaptavist.com wildcard URL is permitted.

When using the Behaviours feature, note that if your Jira instance is using IP allow-lists, you need to expand that to include the Atlassian Forge IP address range and all AWS IP ranges for the region you’re in. Refer to Atlassian’s IP addresses and domains for Atlassian cloud products and AWS IP Ranges for more details.

How to call external application from ScriptRunner for Jira Cloud

ScriptRunner is execute for Jira Cloud can execute rest call to third – party rest api . The simple way is is to test execute these call is to use the Script Console .

To start integrating with an external application, we recommend following the steps below:

  1. contact the support team for the external application and request some example of how to use their rest API .
  2. locate the rest api documentation for the external application .
  3. Test interacting with the REST APIs for the external application on the Script Console  ensure that Script variable are used to store any password or authorization token .

We also recommend using the Post to Slack example Script listener as it provides an example of how to call an external REST API from ScriptRunner for Jira Cloud and can be used as an example to create the script that you require.

HAPI

Currently ScriptRunner for Jira Cloud does not support writing scripts using HAPI, though this is actively in development.