Expression functions
This page lists every built-in function available inside ${{...}} expressions. Function names are not case-sensitive. Calling a function this page does not list, or giving a function more or fewer arguments than its signature below shows, is refused when the workflow or task definition holding the expression is uploaded or imported.
contains
contains(value, searchValue)
Returns true if value contains searchValue, ignoring case.
- When
valueis an array, checks whether any element, read as text, equalssearchValue. - Otherwise, checks whether
searchValueis a substring ofvalue, both read as text.
Inputs and task outputs are text, so read an array from one with fromJSON first. On the raw text, contains looks for a substring.
Examples
# String containment
condition: ${{contains(inputs.name, 'admin')}}
# Array containment
condition: ${{contains(fromJSON(tasks.list.outputs.tags), 'release')}}
startsWith
startsWith(value, prefix)
Returns true if value starts with prefix, ignoring case. Both arguments are read as text, with null as an empty string.
Example
condition: ${{startsWith(inputs.path, '/data/')}}
endsWith
endsWith(value, suffix)
Returns true if value ends with suffix, ignoring case. Both arguments are read as text, with null as an empty string.
Example
condition: ${{endsWith(inputs.filename, '.csv')}}
format
format(template, arg0, arg1, ...)
Replaces positional placeholders {0}, {1}, … in template with the arguments that follow it, read as text. Returns the formatted string.
{0}is the first argument after the template,{1}the second, and so on. A placeholder can appear more than once, in any order.- A placeholder with no matching argument is left as written. Anything else between braces, or a
{that is never closed, is an error. - Escaped braces
{{and}}produce a literal{or}.
Examples
args:
message: ${{format('Hello, {0}! You have {1} items.', inputs.name, inputs.count)}}
# Escaped braces
label: ${{format('{{literal braces}}')}} # produces: {literal braces}
join
join(array)
join(array, separator)
Concatenates the elements of array, each read as text, into a single string, with separator inserted between them. The separator defaults to a comma when omitted. A value that is not an array is returned as text, unchanged.
Examples
args:
csv: ${{join(fromJSON(tasks.list.outputs.items))}}
spaced: ${{join(fromJSON(tasks.list.outputs.items), ' ')}}
toJSON
toJSON(value)
Serializes value to compact JSON. A string becomes a quoted, escaped JSON string, which makes toJSON the way to place a value inside a JSON document. An array or object needs no toJSON when it is the whole result of a ${{...}} block, which already writes it as compact JSON.
Example
args:
payload: '{"name": ${{toJSON(inputs.name)}}}'
With the input Ann, payload is {"name": "Ann"}.
fromJSON
fromJSON(jsonString)
Parses a JSON string and returns the resulting value. Use it to read an array or object from an input or a task output, which are always text.
Example
args:
first_item: ${{fromJSON(tasks.fetch.outputs.json_list)[0]}}
If jsonString is not valid JSON, including an empty value such as an output that was never written, the expression fails, and so does the task that uses it.