...
At runtime, the syntax ${macro-name} will be replaced with whatever value was specified for the key "macro-name." For instance, you might not know the name of a source stream until runtime. You could use, in the source stream's Stream Name configuration:
Code Block |
---|
title | Source Stream Name Macro |
---|
|
${source-stream-name} |
and in the runtime arguments (or preferences) set a key-value pair such as:
Code Block |
---|
title | Source Stream Name Key-Value Pair |
---|
|
source-stream-name: myDemoStream |
Macros can be referential. You might have a server that refers to a hostname and port, and specify this substitution:
Code Block |
---|
|
server-address: ${hostname}:${port} |
and these runtime arguments:
Code Block |
---|
title | Referential Macros Runtime Arguments |
---|
|
hostname: my-demo-host.example.com
port: 9991 |
In a pipeline configuration, you could configure a property with:
Code Block |
---|
title | Server Property Substitution |
---|
|
${server-address} |
expecting that it would be replaced with:
Code Block |
---|
title | Expanded Server Property |
---|
|
my-demo-host.example.com:9991 |
Macro Function
Macro functions allow more complex logic to be run before a substitution occurs and use the following syntax:
Code Block |
---|
title | MacroFunctionMacro Function |
---|
|
${macroFunction(arg1, arg2, arg3)} |
At runtime, the "macroFunction" function will perform some computation with the provided arguments: arg1, arg2, and arg3. Note that whitespace is significant between arguments. The syntax will be replaced with whatever macroFunction evaluates to given the provided arguments.
Currently, there are two support macro functions, logicalStartTime and secureStore.
logicalStartTime
Code Block |
---|
title | logicalStartTime function |
---|
|
${logicalStartTime(timeFormat,offset)} |
The logicalStartTime macro function takes in a time format and an optional offset as arguments and uses the logical start time of a pipeline to perform the substitution. For example, if a pipeline starts on January 1, 2016 at midnight and the following syntax is provided:
Code Block |
---|
title | logicalStartTime example |
---|
|
${logicalStartTime(yyyy-MM-dd'T'HH-mm-ss,1d-4h)} |
would be substituted with the logical start time: 2016-01-01