Global Variables

Overview

Global Variables let you define shared values - constants, configuration objects, lists - that every script across your site can use by name.


How it works

A single Global Variables Script defines values whose names become variables available in every other script. Three formats are supported.

Variable declarations - each top-level const, let or var becomes a global variable:

const TEAM_PROJECT = "PROJ"
const MAX_RETRIES = 3
const CONFIG = { timeout: 5000 }

JSON - a plain JSON object; each key becomes a global variable:

{ "TEAM_PROJECT": "PROJ", "MAX_RETRIES": 3 }

Return object - return { ... } to state explicitly which variables to export:

return {
  TEAM_PROJECT: "PROJ",
  MAX_RETRIES: 3,
}

After saving, all scripts can use these variables directly:

log(TEAM_PROJECT)   // => PROJ
log(MAX_RETRIES)    // => 3

Variables are recalculated on each script execution.


Managing global variables

  1. Open the JiBrok Studio admin page and go to the Global Variables tab
  2. Edit the Global Variables Script in the editor
  3. Click Test - the Test Results tab shows the defined variables with their types and values
  4. Click Save to activate (you can add an optional version note)

Click Help for a format guide with examples.

Global Variables configuration page

</a>

Test results

After a test, the Test Results tab shows:

Column Description
Variable Variable name
Type string, number, boolean, array, object, null, etc.
Value Value preview

Rules and limits

  • The script must produce a plain object (JSON object, top-level declarations, or return { key: value }); arrays and other values are rejected
  • Variable names must be valid identifiers (letters, digits, _, $; not starting with a digit)
  • Reserved names (engine built-ins and API namespaces such as log, issue, Issues, DateUtils) cannot be used
  • Maximum 50 variables per global script
  • Global script size limit: 10 KB
  • eval() is not allowed in the global script. Use eval(scriptId) in regular scripts to include shared code.
  • The global script runs in its own small sandbox: no Jira API calls, no await, no logging, a 1 second time limit, 1,000 loop iterations and 200 AST nodes
  • Only one global script exists per site
  • Version history tracks all changes (Version History tab)

The global script is evaluated before every script run. If a saved global script fails, script runs fail with a global variables error until it is fixed - use Test before Save.

See Limits for all global variable limits.


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