-
Notifications
You must be signed in to change notification settings - Fork 4
/
c0055.yml
49 lines (40 loc) · 1.29 KB
/
c0055.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
doc_meta: |
folder: flow-controll
title: if condition advanced
head: |
Showcase you can use if condition for cmd func and call func too
sections:
- title: What's good about it when you use if with call func?
content: |
The call func actually is very powerfully to create a execution branch with its own stack. So if you use a if condition to call another task, it actually separate the implementation with your own main flow.
Also with multiple if, it is similar to convert the workflow to if/if else, or switch/case etc. Or with embeded if in callee, you could create branched flows so this enrichs the workflow management in very simple way compare to other tools
- title: Demo
log: yes
notes:
goal:
- test the if condition works for cmd and call
tasks:
-
name: task
task:
- func: call
do:
- taska
if: "false"
- func: cmd
dvars:
- name: greet
value: hello
flags: [vvvv]
if: "true"
- func: call
do:
- taska
if: "true"
- name: taska
task:
- func: shell
desc: greet var will be no value as it is a local var for cmd step
do:
- echo "hello from taska"
- echo "{{.greet}} from taska"