Jira Automation Integration

Overview

JiBrok Studio adds two actions to Jira Automation, so a rule can run a script from your library and use its result in later steps:

Action Purpose
Run Script - JiBrok Studio Run a script and use its result in the next steps
Run Script (List) - JiBrok Studio Run a script that returns an array and process each element in a branch

Scripts run with the Run as identity set on the script. Jira Automation does not pass a user to the action, so a script set to Current user runs as the Application - see Who the script runs as.


Setup

1. Enable the Automation Trigger Type

The Automation trigger type is enabled by default. An administrator can switch it off in Administration (Admin Panel -> Admin -> Triggers), which stops both actions.

2. Add an Automation Trigger to a Script

  1. Save the script in the Library and open it in the Console
  2. Go to the Config tab - Triggers
  3. Click Add Trigger and select Automation (“Runs as an action in Jira Automation rules”). A description is optional (up to 2,000 characters)
  4. Save the script

The script must be enabled and have an enabled Automation trigger to be available in Jira Automation. One Automation trigger serves both actions. In the Library such scripts show the Automation badge.

Add Automation trigger to script

</a>

Script returning JSON for automation

</a>

3. Create an Automation Rule

  1. In Jira, go to Project Settings > Automation (or global automation)
  2. Create or edit a rule
  3. Add the action Run Script - JiBrok Studio or Run Script (List) - JiBrok Studio
  4. Select the script (“Select a script to run”). The list shows enabled scripts with an enabled Automation trigger
  5. Adjust Issue Key and Action Input if needed, and save the rule

Notes:

  • The script list is loaded with Jira administrator rights. A rule editor who is not a Jira administrator sees “No scripts with Automation trigger found.” - ask an administrator to configure the action.
  • If the script chosen earlier has lost its trigger, it stays selected and is labelled (no trigger); runs fail until the trigger is restored.

Add component to automation rule

</a>

Search for JiBrok Studio action

</a>


Action inputs

Both actions take the same inputs:

Input Default Description
Script - Required. The script to execute (for the List action it must return an array)
Issue Key {{issue.key}} The issue to run the script for. Supports smart values; clear it for rules without an issue
Action Input empty Extra text passed to the script as params.actionInput. Supports smart values, for example {{issue.key}} or a JSON string you build in the rule

Inside the script, read the Action Input via params.actionInput:

// Passed via Action Input: {{issue.summary}} - {{now}}
log("Received:", params.actionInput)

What the script receives

Variable Content
issue The issue, loaded automatically when Issue Key resolves to a valid key such as PROJ-123
issueKey That key, or null
params The trigger parameters configured on the Automation trigger, plus params.actionInput when Action Input is not empty
event The other data delivered by the rule, with event.issueKey

An issue key that does not look like PROJ-123 (upper-case project key) is ignored and the script runs without an issue.

// Action Input: {"target": "DONE", "notify": true}
const input = params.actionInput ? JSON.parse(params.actionInput) : {}
log('Running for ' + issueKey + ' with target ' + input.target)
return { status: 'ok', key: issueKey }

Automation action script selection

</a>

Automation action configuration

</a>


Who the script runs as

The script runs with the Run as identity set on the script (see Script Console). Current user is not available here: Jira Automation does not pass a user to the action, so a script set to Current user runs as the Application.


Output smart values

The Run Script action returns these values for the following steps of the rule:

Smart value Type Description
{{triggeredJiraScript.success}} boolean true when the script finished without error, otherwise false
{{triggeredJiraScript.result}} string The return value as text (see below), or empty
{{triggeredJiraScript.error}} string Error code when the script failed
{{triggeredJiraScript.executionMs}} integer Script execution time in milliseconds

How the return value becomes result:

Script returns result
A string The string as is
A number or boolean Its text form, for example 5 or true
An object or array A JSON string
Nothing Empty

A script error does not stop the rule: the action completes with success = false and the error code, so you can branch on {{triggeredJiraScript.success}}.

Accessing fields from a JSON result

If your script returns an object (e.g. return { status: "done", count: 5 }), the result is delivered as a JSON string. Use jsonStringToObject() to parse it and access individual fields:

  • {{jsonStringToObject(triggeredJiraScript.result)}} - the parsed object
  • {{jsonStringToObject(triggeredJiraScript.result).status}} - access a specific field
  • {{jsonStringToObject(triggeredJiraScript.result).count}} - access another field

Automation log result data

</a>

Automation log JSON parse result

</a>


Example automation rule

Scenario: When a high-priority issue is created, run a script that assigns a reviewer and posts a Slack-style comment.

  1. Trigger: Issue created
  2. Condition: Priority = Highest or High
  3. Action: Run Script - JiBrok Studio
    • Script: “Auto-assign reviewer”
    • Issue Key: {{issue.key}}
  4. Condition: {{triggeredJiraScript.success}} equals true
  5. Action: Log or send notification with {{triggeredJiraScript.result}}

Automation rule overview

</a>

Automation rule execution log result

</a>

Automation audit log results

</a>


Run Script (List) action

In addition to Run Script - JiBrok Studio, the app provides Run Script (List) - JiBrok Studio. It runs the script once and returns its array to the rule, so a branch runs once per element (“Your script must return an array. Each element will be processed as a separate automation branch.”). It takes the same inputs and the same Automation trigger as the single action.

Use it when a script computes a list of items and you want the rest of the automation rule (send email, add comment, create sub-task, etc.) to execute for each item.

List smart values

Smart value Description
{{triggeredJiraScriptItems.value}} The current element: a string element as is, anything else as JSON
{{jsonStringToObject(triggeredJiraScriptItems.value).fieldName}} A field of an object element
{{triggeredJiraScriptItems.index}} Zero-based position of the element

Rules

  • Only the first 100 elements are returned.
  • The script must return an array. If it returns nothing, the action fails with “Script returned no result. List action requires an array.”; any other type fails with “Script must return an array for list action”.
  • Unlike the single action, a script error fails the List action itself.

Example

// One branch per sub-task key of the issue
return issue.subtasks || []

Then in the automation rule:

  1. Action: Run Script (List) - JiBrok Studio -> the script above
  2. Following branches run once per returned element, with the element available as {{triggeredJiraScriptItems.value}}

Errors

These stop the action with a message in the rule’s audit log:

Message Cause
License required The app license is not active
Automation trigger type is disabled The Automation trigger type is off in Administration
Invalid or missing scriptId No script selected
Script not found / Script is disabled The script was deleted or disabled
No enabled automation trigger for this script The trigger was removed or disabled
Script execution failed Unexpected failure while running

Limits

Scripts run from both actions use the Automation trigger limits: up to 40 seconds of execution and up to 80 Jira API calls per run. See Limits.


History and audit

  • Runs appear in the script’s Run History with trigger Automation.
  • Automation runs are recorded in the script runs audit by default (configurable per trigger type, see Audit Log).
  • Failed runs are collected in the Error Monitor (see Error Monitoring).

Important notes

  • Scripts run with the Run as identity configured on the script; Current user runs as the Application
  • The script must have an enabled Automation trigger - otherwise the action will fail
  • The Automation trigger type must be enabled in Administration
  • Automation trigger limits apply: 40 seconds, 80 API calls per run

Next steps


JiBrok Studio for Jira Cloud JiBrok Studio for Jira Cloud
Release notes
Core Features
Triggers
Extensions
Data Storage
Scripting Overview
JavaScript Engine
Python Engine
Groovy Engine
Scripting API
Administration
Guides