- Output functions
- createFile()
- Math
- JSON
- Object
- String (static)
- Array (static)
- Number (static)
- Type conversion functions
- URI functions
- Global constants
- structuredClone
- Date
- RegExp
- Set
- Map
- Promise
- eval()
- delay()
- Utility classes
- logger
- app
- currentUser
- Timezone classes
- Crypto and encoding
- Date extension classes
- XML classes
- Trigger-specific globals
- Next steps
Part of the Scripting Language reference.
Global functions, objects, and utility classes available in every script. No imports needed.
Output functions
| Function | Log Level |
|---|---|
log() |
log |
print() |
log |
debug() |
debug |
info() |
info |
warn() |
warn |
error() |
error |
Multiple arguments are joined with a space. All six functions work identically except for log level.
log("a", "b", "c") // => a b c
log([1, 2], { x: 3 }) // => [1, 2] {"x":3}
createFile()
Create file artifacts during script execution. Files are returned alongside the script result and can be downloaded from the output panel.
createFile(name, content, mimeType?)
| Parameter | Type | Description |
|---|---|---|
name |
string | Filename (max 255 chars, no path separators or special chars) |
content |
string | File content |
mimeType |
string (optional) | MIME type. Auto-detected from extension if omitted |
Returns a FileDescriptor object: { name, size, mimeType }.
Limits:
| Limit | Value |
|---|---|
| Max files per script | 10 |
| Max single file size | 4 MB |
| Max total file size | 8 MB |
// Create a CSV report
const csv = "Name,Score\nAlice,95\nBob,87"
createFile("report.csv", csv)
// Create with explicit MIME type
createFile("data.json", JSON.stringify(results), "application/json")
Math
| Method / Constant | Description |
|---|---|
Math.abs(x) |
Absolute value |
Math.floor(x) |
Round down |
Math.ceil(x) |
Round up |
Math.round(x) |
Round to nearest integer |
Math.trunc(x) |
Remove fractional part |
Math.min(...) |
Minimum of values |
Math.max(...) |
Maximum of values |
Math.pow(x, y) |
x raised to power y |
Math.sqrt(x) |
Square root |
Math.cbrt(x) |
Cube root |
Math.sign(x) |
Sign of number (-1, 0, or 1) |
Math.log(x) |
Natural logarithm |
Math.log2(x) |
Base-2 logarithm |
Math.log10(x) |
Base-10 logarithm |
Math.exp(x) |
e raised to power x |
Math.random() |
Random number between 0 and 1 |
Math.hypot(...) |
Square root of sum of squares |
Math.sin(x), cos, tan |
Trigonometric (radians) |
Math.asin(x), acos, atan, atan2 |
Inverse trigonometric |
Math.sinh(x), cosh, tanh |
Hyperbolic |
Math.PI |
3.141592653589793 |
Math.E |
2.718281828459045 |
log(Math.abs(-5)) // => 5
log(Math.floor(3.7)) // => 3
log(Math.ceil(3.2)) // => 4
log(Math.round(3.5)) // => 4
log(Math.min(1, 2, 3)) // => 1
log(Math.max(1, 2, 3)) // => 3
log(Math.sqrt(16)) // => 4
JSON
| Method | Description |
|---|---|
JSON.parse(str) |
Parse JSON string. Returns undefined on error. |
JSON.parse(str, reviver) |
Parse with reviver function. |
JSON.stringify(v) |
Convert to JSON string. Returns undefined on error. |
JSON.stringify(v, replacer, space) |
Stringify with replacer and indentation. |
let data = JSON.parse('{"name":"Alice","age":30}')
log(data.name) // => Alice
log(JSON.stringify({ x: 1, y: [2, 3] }))
// => {"x":1,"y":[2,3]}
log(JSON.parse("invalid")) // => undefined
Reviver function:
let result = JSON.parse('{"a":"1","b":"2"}', (key, val) => {
if (key === "") return val
return Number(val)
})
log(result) // => {"a":1,"b":2}
Replacer and space:
log(JSON.stringify({ a: 1, b: 2, c: 3 }, ["a", "c"])) // => {"a":1,"c":3}
log(JSON.stringify({ x: 1 }, null, 2)) // => formatted with indentation
Object
| Method | Description |
|---|---|
Object.keys(obj) |
Array of own property names |
Object.values(obj) |
Array of own property values |
Object.entries(obj) |
Array of [key, value] pairs |
Object.assign(t, s) |
Copy properties from source to target |
Object.freeze(obj) |
Prevent modifications |
Object.fromEntries(arr) |
Create object from [key, value] pairs |
Object.hasOwn(obj, key) |
Check own property (safe) |
Object.is(a, b) |
Same-value equality (NaN-safe) |
Object.getOwnPropertyNames(obj) |
Own property names (forbidden props filtered) |
let obj = { a: 1, b: 2, c: 3 }
log(Object.keys(obj)) // => [a, b, c]
log(Object.values(obj)) // => [1, 2, 3]
log(Object.entries(obj)) // => [[a, 1], [b, 2], [c, 3]]
// Transform values
let doubled = Object.fromEntries(
Object.entries(obj).map(([k, v]) => [k, v * 2])
)
log(doubled) // => {"a":2,"b":4,"c":6}
String (static)
| Method | Description |
|---|---|
String(value) |
Convert value to string |
String.fromCharCode(...) |
Create string from UTF-16 code units |
String.fromCodePoint(...) |
Create string from Unicode code points |
String.format(fmt, ...) |
Java-style formatting (%s, %d, %f, %b, %%, %n) |
Limit:
String.format()pattern length is limited to 500 characters.
log(String.fromCharCode(65, 66, 67)) // => ABC
log(String.format("Hello, %s!", "Alice")) // => Hello, Alice!
log(String.format("%05d", 42)) // => 00042
log(String.format("%8.2f", 3.14)) // => 3.14
Array (static)
| Method | Description |
|---|---|
Array.isArray(v) |
Returns true if value is an array |
Array.from(v) |
Create array from array or string |
Array.from(v, fn) |
Create array with mapper function |
Array.of(...items) |
Create array from arguments |
Array(length) |
Create array of given length |
log(Array.isArray([1, 2])) // => true
log(Array.from("abc")) // => [a, b, c]
log(Array.from([1, 2, 3], x => x * 2)) // => [2, 4, 6]
Number (static)
| Method / Constant | Description |
|---|---|
Number(v) |
Convert to number |
Number.isInteger(v) |
Check if integer |
Number.isSafeInteger(v) |
Check if safe integer |
Number.isNaN(v) |
Check if exactly NaN (strict) |
Number.isFinite(v) |
Check if finite number (strict) |
Number.MAX_SAFE_INTEGER |
9007199254740991 |
Number.MIN_SAFE_INTEGER |
-9007199254740991 |
Number.EPSILON |
~2.22e-16 |
Number.MAX_VALUE |
~1.80e+308 (largest representable number) |
Number.MIN_VALUE |
~5e-324 (smallest positive number) |
Number.POSITIVE_INFINITY |
Positive infinity |
Number.NEGATIVE_INFINITY |
Negative infinity |
Number.NaN |
Not-a-Number value |
Type conversion functions
| Function | Description |
|---|---|
parseInt(v, r) |
Parse string to integer (without r, a 0x prefix parses as hex, otherwise radix 10 - same as JavaScript) |
parseFloat(v) |
Parse string to float |
isNaN(v) |
Check if NaN (coerces to number) |
isFinite(v) |
Check if finite (coerces to number) |
String(v) |
Convert to string |
Number(v) |
Convert to number |
Boolean(v) |
Convert to boolean |
URI functions
| Function | Description |
|---|---|
encodeURI(s) |
Encode a full URI |
decodeURI(s) |
Decode a full URI |
encodeURIComponent(s) |
Encode a URI component |
decodeURIComponent(s) |
Decode a URI component |
Global constants
| Constant | Description |
|---|---|
NaN |
Not-a-Number value |
Infinity |
Positive infinity value |
structuredClone
Deep clone a value (JSON-serializable).
let original = { a: [1, 2], b: { c: 3 } }
let copy = structuredClone(original)
copy.a.push(99)
log(original.a) // => [1, 2]
log(copy.a) // => [1, 2, 99]
Date
Created via Date.create() or new Date(). All chainable methods return a new Date - the original is never modified.
Static methods:
| Method | Description |
|---|---|
Date.create() |
Create date (no args = now, or pass value/components) |
Date.currentDate() |
Create date for current moment (returns Date object) |
Date.now() |
Current timestamp in milliseconds (number) |
Date.parse(s) |
Parse date string to ms. Returns undefined on error. |
Date.UTC(...) |
Returns ms timestamp for UTC date components |
Instance getters: getTime(), getFullYear(), getMonth() (0-11), getDate() (1-31), getDay() (0=Sun), getHours(), getMinutes(), getSeconds(), getMilliseconds(), getTimezoneOffset()
UTC getters: getUTCFullYear(), getUTCMonth(), getUTCDate(), getUTCDay(), getUTCHours(), getUTCMinutes(), getUTCSeconds(), getUTCMilliseconds()
Setters (mutating): setFullYear(), setMonth(), setDate(), setHours(), setMinutes(), setSeconds(), setMilliseconds()
Formatting: toISOString(), toLocaleDateString(), toLocaleString(), toLocaleTimeString(), toDateString(), toTimeString(), toString(), valueOf()
Chainable arithmetic
All methods return a new Date and can be chained:
| Method | Description |
|---|---|
plusDays(n), minusDays(n) |
Add/subtract days |
plusHours(n), minusHours(n) |
Add/subtract hours |
plusMinutes(n), minusMinutes(n) |
Add/subtract minutes |
plusSeconds(n), minusSeconds(n) |
Add/subtract seconds |
plusWeeks(n), minusWeeks(n) |
Add/subtract weeks |
plusMonths(n), minusMonths(n) |
Add/subtract months |
plusYears(n), minusYears(n) |
Add/subtract years |
let d = Date.create("2024-06-15T00:00:00Z")
log(d.plusDays(5).format("yyyy-MM-dd")) // => 2024-06-20
log(d.plusDays(5).plusHours(3).format("HH:mm")) // => 03:00
log(d.format("yyyy-MM-dd")) // => 2024-06-15 (unchanged)
Withers (return new Date)
| Method | Description |
|---|---|
withDayOfMonth(d) |
Set day of month (1-31) |
withMonth(m) |
Set month (1-12, 1=January) |
withYear(y) |
Set year |
withHours(h) |
Set hours |
withMinutes(m) |
Set minutes |
withSeconds(s) |
Set seconds |
let d = Date.create("2024-06-15T00:00:00Z")
log(d.plusMonths(1).withDayOfMonth(1).format("yyyy-MM-dd")) // => 2024-07-01
log(d.withMonth(1).format("MM")) // => 01 (January)
Comparison
| Method | Description |
|---|---|
isAfter(date) |
Returns true if this date is after the argument |
isBefore(date) |
Returns true if this date is before the argument |
isEqual(date) |
Returns true if both dates have the same time |
let d1 = Date.create("2024-06-15T00:00:00Z")
let d2 = Date.create("2024-06-20T00:00:00Z")
log(d1.isBefore(d2)) // => true
log(d1.plusDays(10).isAfter(d2)) // => true
format(pattern)
Formats the date using UTC values. Pattern tokens:
| Token | Description | Example |
|---|---|---|
yyyy |
4-digit year | 2024 |
yy |
2-digit year | 24 |
MM |
Month (01-12) | 06 |
dd |
Day (01-31) | 15 |
HH |
Hours 24h (00-23) | 14 |
hh |
Hours 12h (01-12) | 02 |
mm |
Minutes (00-59) | 30 |
ss |
Seconds (00-59) | 45 |
SSS |
Milliseconds (000-999) | 123 |
a |
AM/PM | PM |
EEEE |
Day of week (full) | Saturday |
EEE |
Day of week (short) | Sat |
Month names (MMMM, MMM) and unpadded tokens (M, d, H, h, m, s) are also supported - see Format Tokens.
Max pattern length: 100 characters.
let d = Date.create("2024-06-15T14:30:45Z")
log(d.format("yyyy-MM-dd")) // => 2024-06-15
log(d.format("dd/MM/yyyy")) // => 15/06/2024
log(d.format("HH:mm:ss")) // => 14:30:45
log(d.format("hh:mm a")) // => 02:30 PM
log(d.format("EEEE, dd MMM yyyy")) // => Saturday, 15 Jun 2024
diff(otherDate)
Returns a DateDiff object with time difference:
| Property/Method | Description |
|---|---|
.days |
Total difference in whole days |
.hours |
Total difference in whole hours |
.minutes |
Total difference in whole minutes |
.seconds |
Total difference in whole seconds |
.milliseconds |
Total difference in milliseconds |
.abs() |
Returns DateDiff with absolute values |
.toString() |
Formatted string (e.g. “3d 12h 30m”) |
let d1 = Date.create("2024-06-10T00:00:00Z")
let d2 = Date.create("2024-06-13T12:30:00Z")
log(d2.diff(d1).days) // => 3
log(d2.diff(d1).hours) // => 84
log(d2.diff(d1).toString()) // => 3d 12h 30m
String.toDate()
Converts an ISO date string to a Date object. Available on all strings:
let d = "2024-06-15T12:00:00Z".toDate()
log(d.plusDays(5).format("dd/MM/yyyy")) // => 20/06/2024
// Useful with Jira API data:
// issue.created.toDate().plusDays(7).isAfter(Date.currentDate())
Basic usage
let d = Date.create(2024, 0, 15) // January 15, 2024
log(d.getFullYear()) // => 2024
log(d.getMonth()) // => 0
log(d.getDate()) // => 15
RegExp
Created via RegExp.create(), new RegExp(), or /pattern/flags literal syntax.
| Method | Description |
|---|---|
r.test(str) |
Returns true if pattern matches |
r.exec(str) |
Returns match array or null |
Properties: source, flags, global, ignoreCase, multiline, dotAll, sticky, unicode, lastIndex
Valid flags: g, i, m, s, u, y
let re = /hello/i
log(re.test("Hello World")) // => true
let m = "abc123def".match(/[0-9]+/)
log(m[0]) // => 123
Named capture groups:
let re = /(?<year>\d{4})-(?<month>\d{2})/
let m = re.exec("2024-06")
log(m.groups) // => {"year":"2024","month":"06"}
Security: Pattern length limited to 200 characters. Nested quantifiers forbidden (ReDoS prevention).
Set
Created via Set.create() or new Set().
| Method / Property | Description |
|---|---|
s.add(value) |
Add value (chainable) |
s.has(value) |
Check if value exists |
s.delete(value) |
Remove a value |
s.clear() |
Remove all values |
s.size |
Number of values |
s.values() / s.toArray() |
Array of all values |
s.forEach(fn) |
Execute function for each value |
let s = Set.create([1, 2, 3])
log(s.size) // => 3
log(s.has(2)) // => true
s.add(4).add(5) // chaining
Map
Created via Map.create() or new Map().
| Method / Property | Description |
|---|---|
m.set(key, val) |
Set key-value pair (chainable) |
m.get(key) |
Get value by key |
m.has(key) |
Check if key exists |
m.delete(key) |
Remove a key-value pair |
m.clear() |
Remove all entries |
m.size |
Number of entries |
m.keys() |
Array of keys |
m.values() |
Array of values |
m.entries() |
Array of [key, value] pairs |
m.forEach(fn) |
Execute function for each entry |
m.toObject() |
Convert to plain object |
let m = Map.create([["x", 1], ["y", 2]])
log(m.get("x")) // => 1
log(m.entries()) // => [[x, 1], [y, 2]]
Promise
The Promise global provides static methods for creating and combining promises. new Promise(executor) and Promise.create(executor) are equivalent.
| Method | Description |
|---|---|
Promise.resolve(value) |
Creates a resolved promise |
Promise.reject(reason) |
Creates a rejected promise |
Promise.create(executor) |
Creates a promise with executor function |
Promise.all(array) |
Resolves when all promises resolve |
Promise.race(array) |
Resolves/rejects with the first settled promise |
Promise.allSettled(array) |
Resolves when all promises settle |
Promise.any(array) |
Resolves with the first fulfilled promise |
Promise.withResolvers() |
Returns { promise, resolve, reject } for deferred resolution |
For detailed usage, examples, and patterns, see Async / Await.
eval()
Loads and executes a saved script by its ID (UUID). Only available in async context.
let result = await eval("550e8400-e29b-41d4-a716-446655440000")
Pass variables to the included script via the second argument:
let result = await eval("550e8400-e29b-41d4-a716-446655440000", { x: 10, y: 20 })
Limits: maxEvalCalls (20), maxIncludeDepth (5). Include errors (circular include, nesting deeper than maxIncludeDepth, script not found) are catchable via try/catch; exceeding maxEvalCalls is not (see Limits).
Important: eval() only works between scripts written in the same language.
delay()
Pauses script execution for the specified number of milliseconds. Only available in async context. The delay is checked against the remaining execution time budget.
await delay(1000) // pause for 1 second
See Async / Await for more details.
Utility classes
JsonSlurper / JsonOutput
var slurper = new JsonSlurper()
var obj = slurper.parseText('{"name":"John"}')
log(JsonOutput.toJson({a: 1})) // => {"a":1}
log(JsonOutput.prettyPrint('{"a":1}')) // formatted JSON
Integer
Java-compatible integer wrapper (32-bit signed range: -2,147,483,648 to 2,147,483,647).
| Method / Constant | Description |
|---|---|
Integer.parseInt(str, radix?) |
Parse string to integer (radix 2-36, default 10) |
Integer.valueOf(str) |
Parse string to integer (same as parseInt) |
Integer.MAX_VALUE |
2,147,483,647 |
Integer.MIN_VALUE |
-2,147,483,648 |
Integer.toString(n, radix?) |
Convert number to string in given radix |
Integer.toBinaryString(n) |
Convert to binary string |
Integer.toHexString(n) |
Convert to hexadecimal string |
Integer.toOctalString(n) |
Convert to octal string |
log(Integer.parseInt("42")) // => 42
log(Integer.parseInt("FF", 16)) // => 255
log(Integer.toHexString(255)) // => ff
log(Integer.toBinaryString(10)) // => 1010
Long
Java-compatible long wrapper (safe integer range).
| Method / Constant | Description |
|---|---|
Long.parseLong(str, radix?) |
Parse string to long (radix 2-36, default 10) |
Long.valueOf(str) |
Parse string to long (same as parseLong) |
Long.MAX_VALUE |
9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER) |
Long.MIN_VALUE |
-9,007,199,254,740,991 (Number.MIN_SAFE_INTEGER) |
Double
Java-compatible double wrapper.
| Method / Constant | Description |
|---|---|
Double.parseDouble(str) |
Parse string to double |
Double.valueOf(str) |
Parse string to double (same as parseDouble) |
Double.isNaN(v) |
Check if value is NaN |
Double.isInfinite(v) |
Check if value is infinite |
Double.isFinite(v) |
Check if value is finite |
Double.MAX_VALUE |
~1.80e+308 |
Double.MIN_VALUE |
~5e-324 |
Double.NaN |
NaN |
Double.POSITIVE_INFINITY |
Positive infinity |
Double.NEGATIVE_INFINITY |
Negative infinity |
Character
Java-compatible character utility class.
| Method | Description |
|---|---|
Character.isDigit(ch) |
Check if character is a digit |
Character.isLetter(ch) |
Check if character is a letter |
Character.isLetterOrDigit(ch) |
Check if character is a letter or digit |
Character.isUpperCase(ch) |
Check if character is uppercase |
Character.isLowerCase(ch) |
Check if character is lowercase |
Character.isWhitespace(ch) |
Check if character is whitespace |
Character.isAlphabetic(ch) |
Check if character is alphabetic |
Character.toUpperCase(ch) |
Convert to uppercase |
Character.toLowerCase(ch) |
Convert to lowercase |
log(Character.isDigit("5")) // => true
log(Character.isLetter("A")) // => true
log(Character.toUpperCase("a")) // => A
LocalDate
Months are 1-12 (not 0-11). Day of week: 1=Monday..7=Sunday (ISO).
Static methods:
| Method | Description |
|---|---|
LocalDate.now() |
Current date |
LocalDate.of(y, m, d) |
Create from components |
LocalDate.parse(str) |
Parse YYYY-MM-DD string |
Instance methods:
| Method | Description |
|---|---|
getYear(), getMonth(), getDayOfMonth() |
Date component getters |
getDayOfWeek() |
ISO day of week (1=Mon..7=Sun) |
plusDays(n), minusDays(n) |
Add/subtract days |
plusMonths(n), minusMonths(n) |
Add/subtract months |
plusYears(n), minusYears(n) |
Add/subtract years |
isAfter(other), isBefore(other), isEqual(other) |
Comparison |
format(pattern) |
Format with pattern (yyyy, MM, dd) |
toString() |
ISO format YYYY-MM-DD |
var date = LocalDate.of(2024, 3, 15)
log(date.format("dd/MM/yyyy")) // => 15/03/2024
log(date.plusDays(10).toString()) // => 2024-03-25
log(date.getDayOfWeek()) // => 5 (Friday)
LocalDateTime
Static methods:
| Method | Description |
|---|---|
LocalDateTime.now() |
Current date and time |
LocalDateTime.of(y, m, d, h?, mi?, s?) |
Create from components |
LocalDateTime.parse(str) |
Parse YYYY-MM-DDTHH:mm:ss string |
Instance methods:
| Method | Description |
|---|---|
getYear(), getMonth(), getDayOfMonth() |
Date component getters |
getHour(), getMinute(), getSecond() |
Time component getters |
getDayOfWeek() |
ISO day of week (1=Mon..7=Sun) |
toLocalDate() |
Extract date part as LocalDate |
plusDays(n), minusDays(n) |
Add/subtract days |
plusMonths(n), minusMonths(n) |
Add/subtract months |
plusYears(n), minusYears(n) |
Add/subtract years |
plusHours(n), minusHours(n) |
Add/subtract hours |
isAfter(other), isBefore(other), isEqual(other) |
Comparison |
format(pattern) |
Format with pattern (yyyy, MM, dd, HH, mm, ss) |
toString() |
ISO format YYYY-MM-DDTHH:mm:ss |
var dt = LocalDateTime.of(2024, 3, 15, 10, 30, 45)
log(dt.format("dd.MM.yyyy HH:mm:ss")) // => 15.03.2024 10:30:45
log(dt.plusHours(2).getHour()) // => 12
SimpleDateFormat
| Method | Description |
|---|---|
format(date) |
Format a Date, LocalDate, or LocalDateTime |
parse(str) |
Parse a date string, returns a Date object |
Pattern tokens: yyyy, yy, MM, dd, HH, mm, ss.
var sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm")
log(sdf.format(LocalDateTime.of(2024, 3, 15, 14, 30, 0))) // => 15/03/2024 14:30
var parsed = sdf.parse("2024-03-15T14:30:00")
log(parsed.getFullYear()) // => 2024
UUID / DecimalFormat
var id = UUID.randomUUID()
log(id.toString()) // => random UUID
log(new DecimalFormat("#,###").format(1234567)) // => 1,234,567
log(new DecimalFormat("0.00").format(3.14159)) // => 3.14
Base64
| Method | Description |
|---|---|
Base64.getEncoder().encodeToString(str) |
Encode string to Base64 |
Base64.getDecoder().decode(str) |
Decode Base64 string to UTF-8 |
var encoded = Base64.getEncoder().encodeToString("Hello")
log(encoded) // => SGVsbG8=
var decoded = Base64.getDecoder().decode("SGVsbG8=")
log(decoded) // => Hello
StringBuilder
| Method | Description |
|---|---|
append(str) |
Append string (chainable) |
insert(index, str) |
Insert string at position (chainable) |
delete(start, end) |
Delete range (chainable) |
reverse() |
Reverse contents (chainable) |
length() |
Current length |
toString() |
Get final string |
var sb = new StringBuilder()
sb.append("Hello").append(" ").append("World")
log(sb.toString()) // => Hello World
log(sb.length()) // => 11
sb.insert(5, ",")
log(sb.toString()) // => Hello, World
sb.reverse()
log(sb.toString()) // => dlroW ,olleH
Duration
| Method | Description |
|---|---|
Duration.ofDays(n) |
Create from days |
Duration.ofHours(n) |
Create from hours |
Duration.ofMinutes(n) |
Create from minutes |
Duration.ofSeconds(n) |
Create from seconds |
Duration.ofMillis(n) |
Create from milliseconds |
Duration.between(t1, t2) |
Duration between two date/datetime objects |
Instance methods:
| Method | Description |
|---|---|
toDays(), toHours(), toMinutes(), toSeconds(), toMillis() |
Convert to units |
plus(other), minus(other) |
Add/subtract durations |
isNegative(), isZero() |
State checks |
abs() |
Absolute value |
toString() |
ISO 8601 format (e.g., PT2H30M) |
var dur = Duration.ofHours(2)
log(dur.toMinutes()) // => 120
var dur2 = Duration.between(
LocalDateTime.of(2024, 1, 1, 10, 0, 0),
LocalDateTime.of(2024, 1, 1, 14, 30, 0)
)
log(dur2.toMinutes()) // => 270
ChronoUnit
Each unit has a between(t1, t2) method for calculating the difference between two date/datetime objects.
| Unit | Description |
|---|---|
ChronoUnit.DAYS |
Difference in days |
ChronoUnit.HOURS |
Difference in hours |
ChronoUnit.MINUTES |
Difference in minutes |
ChronoUnit.SECONDS |
Difference in seconds |
ChronoUnit.MONTHS |
Difference in months |
ChronoUnit.YEARS |
Difference in years |
log(ChronoUnit.DAYS.between(
LocalDate.of(2024, 1, 1),
LocalDate.of(2024, 4, 15)
)) // => 105
log(ChronoUnit.MONTHS.between(
LocalDate.of(2024, 1, 1),
LocalDate.of(2025, 6, 1)
)) // => 17
Period
| Method | Description |
|---|---|
Period.ofDays(n) |
Create from days |
Period.ofMonths(n) |
Create from months |
Period.ofYears(n) |
Create from years |
Period.of(y, m, d) |
Create from components |
Period.between(d1, d2) |
Period between two dates |
Instance methods:
| Method | Description |
|---|---|
getYears(), getMonths(), getDays() |
Component getters |
plus(other), minus(other) |
Add/subtract periods |
isNegative(), isZero() |
State checks |
toString() |
ISO 8601 format (e.g., P1Y2M3D) |
var p = Period.between(
LocalDate.of(2024, 1, 1),
LocalDate.of(2025, 3, 15)
)
log(p.getYears() + "y " + p.getMonths() + "m") // => 1y 2m
Instant
| Method | Description |
|---|---|
Instant.now() |
Current instant |
Instant.ofEpochMilli(ms) |
Create from epoch milliseconds |
Instant.parse(str) |
Parse ISO 8601 string |
Instance methods:
| Method | Description |
|---|---|
toEpochMilli() |
Get epoch milliseconds |
getEpochSecond() |
Get epoch seconds |
plusMillis(n), minusMillis(n) |
Add/subtract milliseconds |
plusSeconds(n), minusSeconds(n) |
Add/subtract seconds |
isAfter(other), isBefore(other) |
Comparison |
toString() |
ISO 8601 format |
var now = Instant.now()
log(now.toEpochMilli() > 0) // => true
var later = now.plusSeconds(60)
log(later.isAfter(now)) // => true
Collections
| Method | Description |
|---|---|
Collections.sort(list) |
Sort list in-place (natural order) |
Collections.reverse(list) |
Reverse list in-place |
Collections.frequency(list, el) |
Count occurrences of element |
Collections.min(list) |
Minimum element |
Collections.max(list) |
Maximum element |
Collections.unmodifiableList(list) |
Frozen copy of list |
Collections.singletonList(el) |
Frozen single-element list |
Collections.emptyList() |
Frozen empty list |
var list = [3, 1, 4, 1, 5]
Collections.sort(list)
log(list) // => [1, 1, 3, 4, 5]
log(Collections.frequency(list, 1)) // => 2
log(Collections.min(list)) // => 1
log(Collections.max(list)) // => 5
Optional
| Method | Description |
|---|---|
Optional.of(value) |
Create with non-null value (throws if null) |
Optional.ofNullable(value) |
Create from value (empty if null) |
Optional.empty() |
Create empty Optional |
Instance methods:
| Method | Description |
|---|---|
isPresent() |
Check if value is present |
isEmpty() |
Check if empty |
get() |
Get value (throws if empty) |
orElse(default) |
Get value or default |
orElseThrow(msg?) |
Get value or throw error |
map(fn) |
Transform value (returns Optional) |
filter(fn) |
Filter value (returns Optional) |
flatMap(fn) |
Transform to Optional (fn must return Optional) |
toString() |
String representation |
var opt = Optional.of(42)
log(opt.orElse(99)) // => 42
var mapped = opt.map(x => x * 2)
log(mapped.get()) // => 84
var empty = Optional.empty()
log(empty.orElse("default")) // => default
Random
| Method | Description |
|---|---|
nextInt(bound?) |
Random integer (0 to bound-1, or 0 to MAX_INT) |
nextDouble() |
Random double (0.0 to 1.0) |
nextFloat() |
Random float (0.0 to 1.0) |
nextBoolean() |
Random boolean |
var rng = new Random()
log(rng.nextInt(100)) // => 0..99
log(rng.nextDouble()) // => 0.0..1.0
log(rng.nextBoolean()) // => true or false
logger
The logger object provides structured logging with named log levels. It works identically to the Output Functions but through a namespaced object. Available in all engine types (JavaScript, Python, Groovy).
| Method | Log Level |
|---|---|
logger.log(...) |
log |
logger.debug(...) |
debug |
logger.info(...) |
info |
logger.warn(...) |
warn |
logger.error(...) |
error |
Multiple arguments are joined with a space. Each call counts toward the maxLogCalls limit (default: 200).
logger.info("Processing issue", issue.key)
logger.warn("Field missing", fieldName)
logger.error("Failed to update", error.message)
logger.info("Processing issue " + issue.key)
logger.debug("Payload: " + JSON.stringify(data))
Note:
loggermethods behave exactly like the top-levellog(),debug(),info(),warn(),error()functions. Theloggerobject is provided for familiarity with standard logging patterns.
app
Read-only object containing the Forge application identity. Useful for building ARIs or conditional logic based on environment.
| Property | Type | Description |
|---|---|---|
app.id |
string |
Forge app ID |
app.version |
string |
Deployed app version |
app.environmentId |
string |
Environment ID (unique per environment) |
app.environmentType |
string |
PRODUCTION, STAGING, or DEVELOPMENT |
app.installationId |
string |
Installation ID (unique per site) |
// Access app identity
log(app.id) // "88117cc1-..."
log(app.environmentType) // "PRODUCTION"
// Environment-conditional logic
if (app.environmentType === 'PRODUCTION') {
log("Running in production")
}
The app object is frozen and cannot be modified by scripts.
currentUser
The current Jira user running the script. This is a lazy variable - the API call to fetch user data only happens when currentUser is first accessed. If your script never references currentUser, no API call is made.
No await is needed - the engine resolves the value automatically on first access.
| Property | Description |
|---|---|
displayName |
User’s display name |
accountId |
Atlassian account ID |
emailAddress |
User’s email address (if visible) |
active |
Whether the account is active |
accountType |
Account type (e.g. atlassian) |
// Simple access - no await needed
log(currentUser.displayName) // => Alice Johnson
log(currentUser.accountId) // => 5b10ac8d82e05b22cc7d4ef5
// Use in template literals
log(`Script run by ${currentUser.displayName}`)
// Destructuring
const { displayName, emailAddress } = currentUser
log(displayName, emailAddress)
// Use in conditions
if (currentUser.accountId === someId) {
log("Running as expected user")
}
The returned object has the same shape as Jira REST API /rest/api/3/myself. The variable is backed by Users.current() internally.
Timezone classes
ZonedDateTime
Timezone-aware date/time class. Combines a date, time, and timezone.
Static methods:
| Method | Description |
|---|---|
ZonedDateTime.now() |
Current date-time in UTC |
ZonedDateTime.now(zoneId) |
Current date-time in specified timezone |
ZonedDateTime.of(y, m, d, h, mi, s, zone) |
Create from components |
ZonedDateTime.parse(str) |
Parse ISO-8601 string with timezone |
Instance methods:
| Method | Description |
|---|---|
getYear(), getMonth(), getDayOfMonth() |
Date component getters |
getHour(), getMinute(), getSecond() |
Time component getters |
getZone() |
Returns the ZoneId |
plusDays(n), minusDays(n) |
Add/subtract days |
plusHours(n), minusHours(n) |
Add/subtract hours |
plusMinutes(n), minusMinutes(n) |
Add/subtract minutes |
plusMonths(n), minusMonths(n) |
Add/subtract months |
isAfter(other), isBefore(other), isEqual(other) |
Comparison |
toLocalDate(), toLocalDateTime(), toInstant() |
Conversion |
format(pattern) |
Format with pattern string or DateTimeFormatter |
toString() |
ISO-8601 with timezone bracket |
def zdt = ZonedDateTime.of(2024, 3, 15, 14, 30, 0, "America/New_York")
log(zdt.format("yyyy-MM-dd HH:mm:ss")) // => 2024-03-15 14:30:00
log(zdt.getZone().getId()) // => America/New_York
def utc = ZonedDateTime.now(ZoneId.of("UTC"))
log(utc.plusHours(5).getHour()) // => current UTC hour + 5
def parsed = ZonedDateTime.parse("2024-03-15T10:30:00Z")
log(parsed.toLocalDate().toString()) // => 2024-03-15
ZoneId
Timezone identifier.
| Method | Description |
|---|---|
ZoneId.of(id) |
Create from timezone string (e.g. “UTC”, “America/New_York”) |
ZoneId.systemDefault() |
Returns UTC |
ZoneId.getAvailableZoneIds() |
List of supported timezone IDs |
def zone = ZoneId.of("Europe/London")
log(zone.getId()) // => Europe/London
DateTimeFormatter
Date/time formatter with pattern-based formatting.
| Method | Description |
|---|---|
DateTimeFormatter.ofPattern(pattern) |
Create from pattern string (max 100 chars) |
DateTimeFormatter.ISO_LOCAL_DATE |
Predefined: yyyy-MM-dd |
DateTimeFormatter.ISO_LOCAL_DATE_TIME |
Predefined: yyyy-MM-ddTHH:mm:ss |
Pattern tokens: yyyy, yy, MM, M, dd, d, HH, H, hh, h, mm, m, ss, s, SSS, a (AM/PM), EEEE (full day name), EEE (short day name), MMMM (full month name), MMM (short month name).
def fmt = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm")
def dt = LocalDateTime.of(2024, 3, 15, 14, 30, 0)
log(fmt.format(dt)) // => 15/03/2024 14:30
log(DateTimeFormatter.ISO_LOCAL_DATE.format(LocalDate.of(2024, 3, 15))) // => 2024-03-15
Crypto and encoding
MessageDigest
Cryptographic hashing (SHA-256, SHA-1, MD5, SHA-512).
| Method | Description |
|---|---|
MessageDigest.getInstance(algorithm) |
Create digest for algorithm |
update(data) |
Add data to hash (chainable) |
digest(data?) |
Compute and return hex hash string |
def md = MessageDigest.getInstance("SHA-256")
md.update("hello")
log(md.digest()) // => 2cf24dba5fb0a30e26e83b2ac5b9e29e...
// One-step hashing
log(MessageDigest.getInstance("MD5").digest("hello")) // => 5d41402abc4b2a76b9719d911017c592
Hash
Convenience utility for one-step hashing.
| Method | Description |
|---|---|
Hash.sha256(data) |
SHA-256 hash as hex string |
Hash.sha1(data) |
SHA-1 hash as hex string |
Hash.md5(data) |
MD5 hash as hex string |
Hash.sha512(data) |
SHA-512 hash as hex string |
log(Hash.sha256("test")) // => 9f86d081884c7d659a2feaa0c55ad015...
log(Hash.md5("test")) // => 098f6bcd4621d373cade4e832627b4f6
URLEncoder / URLDecoder
URL encoding and decoding (UTF-8).
| Method | Description |
|---|---|
URLEncoder.encode(str) |
URL-encode string (spaces become +) |
URLDecoder.decode(str) |
URL-decode string (+ becomes space) |
log(URLEncoder.encode("hello world")) // => hello+world
log(URLEncoder.encode("a=b&c=d")) // => a%3Db%26c%3Dd
log(URLDecoder.decode("hello+world")) // => hello world
// Roundtrip
def encoded = URLEncoder.encode("key=value&name=John Doe")
log(URLDecoder.decode(encoded)) // => key=value&name=John Doe
Date extension classes
Groovy only:
Calendar,DayOfWeek,MonthandLocalTimeare available in the Groovy engine. They are not defined in the JavaScript engine.
Calendar
Java-compatible calendar with mutable fields. Month values are 0-based (January=0).
Static methods:
| Method | Description |
|---|---|
Calendar.getInstance() |
Create calendar for current time |
Field constants: Calendar.YEAR (1), Calendar.MONTH (2), Calendar.DAY_OF_MONTH (5), Calendar.HOUR_OF_DAY (11), Calendar.MINUTE (12), Calendar.SECOND (13), Calendar.DAY_OF_WEEK (7), Calendar.MILLISECOND (14)
Day constants: Calendar.SUNDAY (1) through Calendar.SATURDAY (7)
Month constants: Calendar.JANUARY (0) through Calendar.DECEMBER (11)
Instance methods:
| Method | Description |
|---|---|
get(field) |
Get field value |
set(field, value) |
Set field value |
set(y, m, d, h?, mi?, s?) |
Set multiple components |
add(field, amount) |
Add to field (rolls other fields) |
getTime() |
Get as Date object |
getTimeInMillis() |
Get epoch milliseconds |
clone() |
Create independent copy |
before(other), after(other) |
Compare calendars |
getActualMaximum(field) |
Max value for field (e.g., days in month) |
def cal = Calendar.getInstance()
cal.set(Calendar.YEAR, 2024)
cal.set(Calendar.MONTH, Calendar.MARCH)
cal.set(Calendar.DAY_OF_MONTH, 15)
log(cal.get(Calendar.YEAR)) // => 2024
log(cal.get(Calendar.MONTH)) // => 2 (March, 0-based)
cal.add(Calendar.DAY_OF_MONTH, 20)
log(cal.get(Calendar.MONTH)) // => 3 (April)
// Check days in February (leap year)
cal.set(2024, 1, 1)
log(cal.getActualMaximum(Calendar.DAY_OF_MONTH)) // => 29
DayOfWeek
Java 8+ day-of-week enum (ISO: 1=Monday through 7=Sunday).
| Method / Constant | Description |
|---|---|
DayOfWeek.MONDAY through DayOfWeek.SUNDAY |
Day constants |
DayOfWeek.of(value) |
Create from number (1-7) |
DayOfWeek.valueOf(name) |
Create from name (e.g., “MONDAY”) |
DayOfWeek.values() |
Array of all 7 days |
getValue() |
Numeric value (1-7) |
name() |
Name string (e.g., “MONDAY”) |
plus(n), minus(n) |
Arithmetic with wrapping |
log(DayOfWeek.MONDAY.getValue()) // => 1
log(DayOfWeek.SUNDAY.getValue()) // => 7
log(DayOfWeek.of(5).name()) // => FRIDAY
log(DayOfWeek.SATURDAY.plus(2).name()) // => MONDAY (wraps)
Month
Java 8+ month enum (1=January through 12=December).
| Method / Constant | Description |
|---|---|
Month.JANUARY through Month.DECEMBER |
Month constants |
Month.of(value) |
Create from number (1-12) |
Month.valueOf(name) |
Create from name (e.g., “JANUARY”) |
Month.values() |
Array of all 12 months |
getValue() |
Numeric value (1-12) |
name() |
Name string (e.g., “JANUARY”) |
length(isLeapYear) |
Days in month |
plus(n), minus(n) |
Arithmetic with wrapping |
log(Month.FEBRUARY.length(true)) // => 29 (leap year)
log(Month.FEBRUARY.length(false)) // => 28
log(Month.NOVEMBER.plus(3).name()) // => FEBRUARY (wraps)
LocalTime
Time without date or timezone (hours, minutes, seconds).
Static methods:
| Method | Description |
|---|---|
LocalTime.now() |
Current time |
LocalTime.of(h, m, s?) |
Create from components |
LocalTime.parse(str) |
Parse “HH:mm” or “HH:mm:ss” |
LocalTime.MIDNIGHT |
00:00 |
LocalTime.NOON |
12:00 |
LocalTime.MIN |
00:00:00 |
LocalTime.MAX |
23:59:59 |
Instance methods:
| Method | Description |
|---|---|
getHour(), getMinute(), getSecond() |
Component getters |
plusHours(n), minusHours(n) |
Add/subtract hours (wraps at 24) |
plusMinutes(n), minusMinutes(n) |
Add/subtract minutes |
plusSeconds(n), minusSeconds(n) |
Add/subtract seconds |
isBefore(other), isAfter(other) |
Comparison |
compareTo(other) |
Compare (-1, 0, 1) |
withHour(h), withMinute(m), withSecond(s) |
Replace component |
toSecondOfDay() |
Seconds since midnight |
format(pattern) |
Format with HH, mm, ss tokens |
toString() |
“HH:mm” or “HH:mm:ss” |
def time = LocalTime.of(14, 30, 45)
log(time.toString()) // => 14:30:45
log(time.getHour()) // => 14
log(time.toSecondOfDay()) // => 52245
log(LocalTime.of(22, 0).plusHours(5).getHour()) // => 3 (wraps)
log(LocalTime.NOON.toString()) // => 12:00
XML classes
MarkupBuilder
Builds XML/HTML strings programmatically with proper escaping.
| Method | Description |
|---|---|
new MarkupBuilder() |
Create a new builder |
element(name, attrs?, text?, body?) |
Add element |
text(str) |
Add escaped text |
raw(str) |
Add unescaped content |
toString() |
Get resulting XML string |
def builder = new MarkupBuilder()
builder.element("html", { html ->
html.element("body", { body ->
body.element("h1", "Hello World")
body.element("p", ["class": "intro"], "Welcome")
body.element("br")
})
})
log(builder.toString())
// => <html><body><h1>Hello World</h1><p class="intro">Welcome</p><br/></body></html>
Security: Element/attribute names from the forbidden list (__proto__, constructor, etc.) are blocked or skipped. Maximum nesting depth: 20.
XmlSlurper
Parses XML strings into navigable object trees.
| Method | Description |
|---|---|
new XmlSlurper() |
Create a new slurper |
parseText(xml) |
Parse XML string, returns root node |
Node methods:
| Method | Description |
|---|---|
name() |
Element name |
text() |
Text content (recursive) |
attr(name) |
Attribute value (empty string if missing) |
attributes() |
All attributes as object |
children() |
Array of child nodes |
child(name) |
First child with given name (throws if not found) |
childList(name) |
All children with given name |
size() |
Number of children |
def xml = '''
<response>
<issues>
<issue key="PROJ-1">
<summary>Bug fix</summary>
<status>Done</status>
</issue>
<issue key="PROJ-2">
<summary>Feature</summary>
<status>Open</status>
</issue>
</issues>
</response>
'''
def slurper = new XmlSlurper()
def root = slurper.parseText(xml)
def issues = root.child("issues").childList("issue")
log(issues.size()) // => 2
log(issues[0].attr("key")) // => PROJ-1
log(issues[0].child("summary").text()) // => Bug fix
Security: XML input size limited to maxStringSize. Maximum nesting depth: 20.
Arrays
Java-compatible array utility class.
Note: In scripts run by JiBrok Studio, the name
Arraysis bound to the Arrays utility namespace (sortBy,groupBy,chunk, …), which replaces this Java-style class. The methods below are therefore not reachable throughArraysin a normal script run; use list methods instead (list.sort(),list.toString(), …).
| Method | Description |
|---|---|
Arrays.asList(...) |
Create list from arguments |
Arrays.copyOf(arr, len) |
Copy array with new length |
Arrays.sort(arr) |
Sort array in-place |
Arrays.fill(arr, val) |
Fill array with value |
Arrays.equals(a, b) |
Compare two arrays |
Arrays.toString(arr) |
String representation |
def list = Arrays.asList(3, 1, 4, 1, 5)
Arrays.sort(list)
log(list) // => [1, 1, 3, 4, 5]
def copy = Arrays.copyOf([1, 2, 3], 5)
log(copy) // => [1, 2, 3, null, null]
Trigger-specific globals
Some triggers expose a top-level frozen object alongside the standard globals.
jqlFunction (JQL function trigger)
When a script is invoked from a custom JQL function (issue in jbExec("name", arg1, ...) in JQL), a frozen jqlFunction object is added to the top-level scope:
| Field | Type | Description |
|---|---|---|
jqlFunction.name |
string | Lowercased function name (the value passed as the first argument to jbExec). |
jqlFunction.operator |
string | "in" or "not in". |
jqlFunction.args |
array | User-supplied arguments (up to 10), as a native JS array - no parsing needed. |
The same data is also exposed as event.jqlFunction for symmetry with other event-style triggers.
const sourceKey = jqlFunction.args[0];
const linkType = jqlFunction.args[1] || 'blocks';
const issue = Issues.get(sourceKey);
if (!issue) return [];
return issue.links.filter(l => l.type === linkType).map(l => l.targetKey);
The script must return one of:
string[]- issue keys (wrapped asissuekey in (...))number[]- numeric issue IDs (wrapped asid in (...), recommended for performance)string- raw JQL fragment (wrapped in parentheses, sanitized)[]- empty result
See Custom JQL Functions for the full reference.
Next steps
- JS: Type Methods - Instance methods on strings, arrays, numbers (includes 28 Automation-compatible string methods)
- JS: Language Basics - Core language features
- JS: Async/Await - Promise API,
delay()and async patterns - JS: Differences from Standard JS - Behavioral differences
- Limits - Resource limits such as
maxEvalCallsandmaxStringSize - Scripting Language - Overview and sandbox details
