Conditions
Apart from skip property, which have to be set explicitly, tasks can be skipped based on condition. when condition can be set for tasks and based on the evaluation of that condition then task will be skipped or not.
The result of each condition sets skip property of the task. So even if skip was not explicitly set if the task have when condition then skip property will be set (based on the result of the when condition)
Priority
skip have higher priority and its evaluated before when conditions
Default
If skip property is not defined then its auto added and set to false
Loop
when condition is evaluated before the task is ran. This means that any defined loop will be ran post when evaluation and not for each element
Syntax
Operators
Syntax of when is the same as the one used in filter property.
The following operators can be used to compare items:
eq- equal==ne- not equal!=gt- grater than>ge- greater than or equal>=lt- less than<le- less than or equal<=sw- string starts withew- string ends withso- string is substring of
Multiple conditions can be combined with and and or operators. Brackets are also respected.
1 2 3 | |
Properties
Result from previous tasks can be used:
-
Logical - few special properties can be checked:
-
length- compare the length of the returned data1 2 3 4 5 6 7 8
- name: Some task operation: app.get filter: some filter here - name: Another task operation: app.delete source: Some task when: $${Some task|length} > 2In the example above, the second task will be ran only if
Some taskis returning more than 2 entries -
skip- compare theskipproperty of the previous task1 2 3 4 5 6 7 8 9
- name: Some task operation: app.get filter: some filter here skip: true - name: Another task operation: app.delete source: Some task when: $${Some task|skip} eq falseIn the example above, the second task will be ran only if
Some taskis being skipped.`
-
-
Property - conditions can be checked against specific property, returned from previous task. Since tasks can return multiple entities (multiple apps, streams, users, tasks etc.) when checking for specific property we should have in mind that.
-
any - the default behavior will be to check if ANY of the returned values satisfies the condition
1 2 3 4 5 6 7 8 9
- name: Some task operation: app.get filter: some filter here skip: true - name: Another task operation: app.delete source: Some task when: $${Some task#name} sw "Something"In the above example the
whencondition will be evaluated astrueas long as at least one of the apps, returned fromSome tasktask, have a name that starts withSomething -
all - if we want to check if all entities are satisfying the condition then we have to use
!when specifying the property:1 2 3 4 5 6 7 8 9
- name: Some task operation: app.get filter: some filter here skip: true - name: Another task operation: app.delete source: Some task when: $${Some task#name!} sw "Something" //! is important hereIn the above example the
whencondition will betrueif the name of ALL returned apps starts withSomething
-