Flow Control
Flow order control.
Available actions:
    sequence (sync) - execute sub-flows in a sequence
    parallel (async) - execute sub-flows in parallel
    attachment - execute flow described in different file / url
    repeat - repeat action multiple times
    retry - repeat action till it succeeds or fails maximum number of times
    for each of - execute action for each item in the array
    while - execute action while condition satisfies
    switch (conditional) - execute different actions based on the value
    try-catch-finally - "try / catch / finally"
    sleep - sleep for given amount of second
    template - execute action described in template string
    virtual - create virtual action handler
    error - rise error
    echo - print message to stdout
    void - does nothing

Action Handler: Sequential steps execution

Run steps one by one, if any of steps fail - chain of execution will stop on it.
Note: parameters for each action will be cloned. Meaning each action will start its own branch unless shareParameters option is used.
ID: com.fireblink.fbl.flow.sequence
Aliases:
    fbl.flow.sequence
    flow.sequence
    sequence
    sync
    --
Example 1: Base Declaration
1
# Run actions in a sequence
2
'--':
3
- ctx:
4
'.':
5
inline:
6
something: true
7
- ctx:
8
fromFile:
9
files:
10
- test.yml
Copied!
Example 2: Detailed Declaration
1
# Run actions in a sequence
2
'--':
3
# [optional] whether to share parameters between actions instead of making a clone.
4
# Default value: false, e.g. make cloned parameters for each action in a sequence.
5
shareParameters: false
6
7
# [required] list of actions to invoke in a sequence
8
actions:
9
- ctx:
10
'.':
11
inline:
12
something: true
13
- ctx:
14
fromFile:
15
files:
16
- test.yml
Copied!
Warning: shareParameters usage is considered an anti-pattern

Action Handler: Parallel steps execution

Run all steps in parallel. If any of steps will fail - it will not affect others. However parallel step itself will be marked as failed.
ID: com.fireblink.fbl.flow.parallel
Aliases:
    fbl.flow.parallel
    flow.parallel
    parallel
    async
    ||
Example 1: Base syntax
1
# Run steps in parallel
2
'||':
3
- ctx:
4
'.':
5
inline:
6
something: true
7
- ctx:
8
fromFile:
9
files:
10
- test.yml
Copied!
Example 2: Alternative syntax
1
'||':
2
# [optional] whether to share parameters between actions instead of making a clone.
3
# Default value: false, e.g. make cloned parameters for each action in a sequence.
4
shareParameters: false
5
6
# [required] actions to invoke in parallel
7
actions:
8
- ctx:
9
'.':
10
inline:
11
something: true
12
- ctx:
13
fromFile:
14
files:
15
- test.yml
Copied!

Action Handler: Attached flow

Allows to reference external flow by its pass. Helps to logically split big flows for better organized structure.
ID: com.fireblink.fbl.flow.attachment
Aliases:
    fbl.flow.attachment
    flow.attachment
    attachment
    @
Example 1: Specify flow file
1
# Run steps from external flow file or package (*.tar.gz)
2
'@': flow.yml
Copied!
Example 2: Specify directory
1
# Run steps from external flow file (index.yml) inside "flow" directory
2
# Note: slash in the end of path is not required
3
'@': flow/
Copied!
Example 3: Specify url to download a package
1
# Run steps from external flow file (index.yml) inside "flow" directory
2
# Note: slash in the end of path is not required
3
'@': http://some.host/flow.tar.gz
Copied!
Example 4: Specify target inside the package
1
'@':
2
# [required] path or url to download the package
3
path: flow.tar.gz
4
# [optional] specify custom flow entry file name inside the package
5
target: custom.yml
Copied!
Example 5: Custom HTTP headers
1
'@':
2
# [required] path or url to download the package
3
path: http://some.host/flow.tar.gz
4
5
# [optional] specify custom flow entry file name inside the package
6
target: custom.yml
7
8
# [optional] http parameters
9
http:
10
# [optional] custom http headers
11
headers:
12
Authorization: Basic YWRtaW46YWRtaW4=
13
14
# [optional] cache downloaded package inside $FBL_HOME/cache folder
15
cache: true
Copied!

Action Handler: Repeat flow

Repeat action multiple times.
ID: com.fireblink.fbl.flow.repeat
Aliases:
    fbl.flow.repeat
    flow.repeat
    repeat
Example:
1
repeat:
2
# [optional] whether to share parameters between actions instead of making a clone.
3
# Default value: false, e.g. make cloned parameters for each action in a sequence.
4
shareParameters: false
5
6
# [required] number of iterations
7
times: 2
8
9
# [optional] whether each iteration should wait previous to complete or run in parallel
10
# Default value: false
11
async: false
12
13
# [required] action to run
14
action:
15
# run flow_0.yml and flow_1.yml flows
16
@: flow_<%- iteration.index %>.yml
Copied!

Action Handler: Retry flow

Retry action multiple times till it passes or reach max failure attempts.
ID: com.fireblink.fbl.flow.retry
Aliases:
    fbl.flow.retry
    flow.retry
    retry
Example:
1
retry:
2
# [required] number of attempts to run the action
3
attempts: 2
4
5
# [required] action to run
6
action:
7
sleep: 1
8
9
# [optional] allows to record last error code from last failed attempt
10
# Note: will only be executed if all attempts are failed
11
errorCode:
12
# [optional] assign error code to context field
13
# Follows common assignment logic practicies https://fbl.fireblink.com/plugins/common#assign-to
14
assignTo: '$.ctx.errorCode'
15
16
# [optional] push error code to context field
17
# Follows common push logic practicies https://fbl.fireblink.com/plugins/common#push-to
18
pushTo: '$.ctx.errorCode'
Copied!

Action Handler: For Each

Allows to execute action for every item in the array or key of an object.
ID: com.fireblink.fbl.flow.foreach
Aliases:
    fbl.flow.foreach
    flow.foreach
    foreach
    each
Example: Array
1
each:
2
# [optional] whether to share parameters between actions instead of making a clone of parameters.
3
# Default value: false, e.g. make cloned parameters for each action in a sequence.
4
shareParameters: false
5
6
# [required] array to iterate over
7
of: [1, 2, 3]
8
9
# [required] action to invoke on every iteration
10
action:
11
ctx:
12
test_<%- iteration.index %>:
13
# assign 1,2,3 to test_0, test_1, test_3
14
inline: $ref:iteration.value
Copied!
Example: Object
1
each:
2
# [optional] whether to share parameters between actions instead of making a clone of parameters.
3
# Default value: false, e.g. make cloned parameters for each action in a sequence.
4
shareParameters: false
5
6
# [required] object to iterate over
7
of:
8
a: 1
9
b: 2
10
11
# [required] action to invoke for each iteration
12
action:
13
ctx:
14
test_<%- iteration.index %>:
15
# assign 1a to test_0 and b2 to test_1 values
16
inline: <%- iteration.value %><%- iteration.name %>
Copied!

Action Handler: Switch flow

Allows to run action based on some condition
ID: com.fireblink.fbl.flow.switch
Aliases:
    fbl.flow.switch
    flow.switch
    switch
    if
    ?
Example:
1
'?':
2
# [required] value to check
3
value: <% ctx.test %>
4
5
# [requied] actions to run on specific value
6
is:
7
# execute "foo.yml" if "foo"
8
foo:
9
@: foo.yml
10
11
# execute "bar.yml" if "bar"
12
bar:
13
@: bar.yml
14
15
# [optional] if no match found "else" handler will get executed
16
else:
17
@: else.yml
Copied!

Action Handler: While

Runs action till condition is successful or not (based on configuration).
ID: com.fireblink.fbl.flow.while
Aliases:
    fbl.flow.while
    flow.while
    while
Example: Positive condition check
1
while:
2
# [optional] whether to share parameters between actions instead of making a clone of parameters.
3
# Default value: false, e.g. make cloned parameters for each action in a sequence.
4
shareParameters: false
5
6
# [required] value to check
7
value: <%- ctx.something %>
8
9
# [required] if value IS equal to provided one - action will get executed
10
is: true
11
12
# [required] action to run
13
action:
14
'@': something.yml
Copied!
Example: Negative condition check
1
while:
2
# [optional] whether to share parameters between actions instead of making a clone of parameters.
3
# Default value: false, e.g. make cloned parameters for each action in a sequence.
4
shareParameters: false
5
6
# [required] value to check
7
value: <%- ctx.something %>
8
9
# [required] if value IS NOT equal to provided one - action will get executed
10
not: true
11
12
# [required] action to run
13
action:
14
'@': something.yml
Copied!

Action Handler: Sleep

Sleep for a given amount of seconds.
ID: com.fireblink.fbl.flow.sleep
Aliases:
    fbl.flow.sleep
    flow.sleep
    sleep
Example:
1
# sleep for a minute
2
sleep: 60
Copied!

Action Handler: Try - Catch - Finally Flow

Allows to run sub-step in isolation causing its failure to be ignored by parent step. Optionally catch and finally steps can be invoked.
If catch or finally step block will be failed - this step will also be marked as failed even try block passes successfully.
ID: com.fireblink.fbl.flow.try
Aliases:
    fbl.flow.try
    flow.try
    try
Example:
1
try:
2
# [required] action to run
3
action:
4
@: foo.yml
5
6
# [optional] call error.yml if foo.yml failed
7
catch:
8
@: error.yml
9
10
# [optional] error code assignment, can be used to better handle error processing inside catch/final actions
11
errorCode:
12
# [optional] assign error code to context field
13
# Follows common assignment logic practicies https://fbl.fireblink.com/plugins/common#assign-to
14
assignTo: '$.ctx.errorCode'
15
16
# [optional] push error code to context field
17
# Follows common push logic practicies https://fbl.fireblink.com/plugins/common#push-to
18
pushTo: '$.ctx.errorCode'
19
20
# [optional] call cleanup.yml either after successful execution of foo.yml or error.yml
21
finally:
22
@: cleanup.yml
Copied!

Action Handler: Template

Run action based on dynamically constructed template. This is handy as you generally can not dynamically construct YAML with EJS template inside most of the actions.
E.g: following is invalid:
1
ctx:
2
something: <% [1, 2, 3].forEach(item => { %>
3
- <%- item %>
4
<% }) %>
Copied!
It will fail as upon processing everything that goes after something will be treated as string, causing to produce following action:
1
ctx:
2
something: '-1\n -2\n -3'
Copied!
But there is a template handler that can help you with that.
ID: com.fireblink.fbl.flow.template
Aliases:
    fbl.flow.template
    flow.template
    template
    tpl
Example:
1
tpl: |-
2
ctx:
3
something:
4
<% [1, 2, 3].forEach(item => { %>
5
- <%- item %>
6
<% }) %>
Copied!
that will generally produce:
1
ctx:
2
something: [1, 2, 3]
Copied!

Action Handler: Virtual

Allows to create virtual action handler for another action (that can be represented as one of the flows).
ID: com.fireblink.fbl.flow.virtual
Aliases:
    fbl.flow.virtual
    flow.virtual
    virtual
Example:
1
virtual:
2
# [required] virtual handler ID
3
id: handler.id
4
5
# [optional] aliases for the handler to reference
6
aliases:
7
- handler.alias
8
9
# [optional] JSON Schema of options that can/should be passed to the generated handler
10
parametersSchema:
11
type: object
12
properties:
13
test:
14
type: string
15
16
# [optional] default parameters and merge function
17
# Note: if no mergeFunction or modifiers is provided defaults with parameters will be deeply merged.
18
# Upon merge arrays will be concatenated.
19
defaults:
20
# [required] default values
21
values:
22
test: yes
23
24
# [optional] merge modification functions for given paths
25
# This is a recommended way of overriding merge behaviour.
26
# Use "mergeFunction" only when you need to do something really unique.
27
# "parameters" - represents field state by given path
28
# "defaults" - its default value if any
29
modifiers:
30
$.test: |-
31
return parameters + defaults
32
33
# [optional] custom merge function
34
# Use it only when "modifiers" functionality isn't enough
35
# "parameters" - represents provided parameters
36
# "defaults" - defaults by itself
37
mergeFunction: |-
38
return parameters.test + defaults.test
39
40
# [optional] Change working directory location based on the place of virtual execution
41
# instead of declaration.
42
#
43
# By default all relative paths are resolved based on the place where virtual action is declared.
44
# If you need to change the behavior - set this property to "true".
45
#
46
# Parameters:
47
# $.parameters.wd - will be dynamically set to either working directory where virtual
48
# is declared or place where it will be invoked.
49
#
50
# $.parameters.pwd - always points to the working directory where virtual was declared.
51
dynamicWorkDir: true
52
53
# [required] action to invoke
54
action:
55
ctx:
56
some_field:
57
# Note: you may use "parameters" to reference passed options to the virtual handler
58
# These options are first pre-validated with provided validationSchema (if any)
59
inline: <%- parameters.test %>
Copied!
Then you can reference your generated handler like any other:
1
handler.id:
2
test: some_field_value
Copied!

Action Handler: Invoke

Allows to execute action passed as parameter. Can be used in pair with virtual to pass flow actions as parameters and create reach execution flow patterns.
ID: com.fireblink.fbl.flow.invoke
Aliases:
    fbl.flow.invoke
    flow.invoke
    invoke
Example:
1
# Invoke action described in parameters `action` field
2
invoke: $ref:parameters.action
Copied!

Action Handler: Error

Throw error upon execution with given message.
ID: com.fireblink.fbl.flow.error
Aliases:
    fbl.flow.error
    flow.error
    error
Example:
1
error: 'message'
Copied!

Action Handler: Echo

Print message to console
ID: com.fireblink.fbl.flow.echo
Aliases:
    fbl.flow.echo
    flow.echo
    echo
Example:
1
echo: 'message'
Copied!

Action Handler: Void

Action handler that does nothing. Main usecase to bypass limitations of other action handlers that require action handler to be provided as an option, but you might not want to do that for some reason.
ID: com.fireblink.fbl.flow.void
Aliases:
    fbl.flow.void
    flow.void
    void
Example:
1
pipeline:
2
'--':
3
- void
Copied!
Last modified 1yr ago