Advanced variable format options
The formatting of the variable interpolation depends on the data source, but there are some situations where you might want to change the default formatting.
For example, the default for the MySql data source is to join multiple values as comma-separated with quotes: 'server01','server02'
. In some cases, you might want to have a comma-separated string without quotes: server01,server02
. You can make that happen with advanced variable formatting options listed below.
Syntax: ${var_name:option}
If any invalid formatting option is specified, then glob
is the default/fallback option.
An alternative syntax (that might be deprecated in the future) is [[var_name:option]]
.
Formats variables with multiple values as a comma-separated string.
servers = ['test1', 'test2']
String to interpolate: '${servers:csv}'
Interpolation result: 'test1,test2'
Formats single- and multi-valued variables into a comma-separated string, escapes "
in each value by \"
and quotes each value with "
.
servers = ['test1', 'test2']
String to interpolate: '${servers:doublequote}'
Interpolation result: '"test1","test2"'
Formats variables with multiple values as a comma-separated string.
servers = ['test1', 'test2']
String to interpolate: '${servers:json}'
Interpolation result: '["test1", "test2"]'
Formats single and multi valued variables for use in URL parameters.
servers = ['foo()bar BAZ', 'test2']
String to interpolate: '${servers:percentencode}'
Interpolation result: 'foo%28%29bar%20BAZ%2Ctest2'
Formats variables with multiple values into a pipe-separated string.
servers = ['test1.', 'test2']
String to interpolate: '${servers:pipe}'
Interpolation result: 'test1.|test2'
Turns off data source-specific formatting, such as single quotes in an SQL query.
servers = ['test1.', 'test2']
String to interpolate: '${var_name:raw}'
Interpolation result: '{test.1,test2}'
Formats variables with multiple values into a regex string.
servers = ['test1.', 'test2']
String to interpolate: '${servers:regex}'
Interpolation result: '(test1\.|test2)'
Formats single- and multi-valued variables into a comma-separated string, escapes '
in each value by \'
and quotes each value with '
.
servers = ['test1', 'test2']
String to interpolate: '${servers:singlequote}'
Interpolation result: "'test1','test2'"
Formats single- and multi-valued variables into a comma-separated string, escapes '
in each value by ''
and quotes each value with '
.
servers = ["test'1", "test2"]
String to interpolate: '${servers:sqlstring}'
Interpolation result: "'test''1','test2'"
Formats single- and multi-valued variables into their text representation. For a single variable it will just return the text representation. For multi-valued variables it will return the text representation combined with +
.
servers = ["test1", "test2"]
String to interpolate: '${servers:text}'
Interpolation result: "test1 + test2"