-
Notifications
You must be signed in to change notification settings - Fork 4
/
f0188.yml
87 lines (76 loc) · 2.05 KB
/
f0188.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
doc_meta: |
folder: flow-controll
title: finally/resuce support in subtask level
head: |
Showcases that you could make the workflow to pass through with cleanup, however you can still make the exit code as none zero to mark it fail
sections:
- title: Demo
log: yes
related:
refs:
- title: shell func
link: ../../quick-start/c0002/
- title: error handling
link: ../../test-debug/error_handling/
- title: finally and rescue
link: ../../flow-controll/c0174/
- title: finally block
link: ../../flow-controll/c0183/
- title: finally block
link: ../../flow-controll/c0184/
- title: finally block
link: ../../flow-controll/c0187/
notes:
- add finally support to tasks level
tasks:
-
name: task
task:
-
func: call
desc: |
expect sub_task to close file each time in loop iteration
loop:
- item1
- item2
- item3
do:
- sub_task
-
name: sub_task
task:
-
func: cmd
do:
- name: print
cmd: 'case {{.loopitem}}'
-
func: shell
name: step1
desc: conditionall trigger the error
do:
- echo "case {{.loopitem}} "
- echo "hello"|grep "world"
if: '{{eq .loopitem "item2"}}'
-
func: cmd
name: step2
desc: |
in this case, since there is no ignoreError, the exception was captured by task level finaly code block
opened file is safely closed
to make the flow to continue to reach step2, use ignoreError
do:
- name: print
cmd: step 2
desc: |
without rescue, the execution will return a non-zero return code in shell and also report the error
with rescue, the program will return 0
rescue: true
finally:
-
func: shell
name: close_file
desc: |
ensure the opened file is closed
do:
- echo "close the file ....."