-
Notifications
You must be signed in to change notification settings - Fork 4
/
f0171.yml
57 lines (47 loc) · 1.42 KB
/
f0171.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
doc_meta: |
folder: flow-controll
title: final cleanup when shell exceution fails
head: |
demo the finally element will guarantee the resource cleanup when shell execution fails
sections:
- title: Demo
log: yes
- title: what will happen if there is no ignoreError for the task
content: |
The shell step failed, the finally step invokes the close_file task to ensure the opened file is closed
In this way, user has the control to gracefully cleanup all relevant resources used and terminate the process to continue further. The task fails, but it is intended.
In case user would like to continue, use can still choose to use ignoreError, then it will continue to execute the "step 2"
related:
refs:
- title: shell func
link: ../../quick-start/c0002/
- title: error handling
link: ../../test-debug/error_handling/
tasks:
-
name: task
task:
-
func: shell
desc: |
task fails
do:
- echo "open a file ....."
- echo "reading the file" |grep "cause an exception"
finally: close_file
-
func: cmd
desc: step 2
do:
- name: print
cmd: step 2
-
name: close_file
task:
-
func: shell
name: close_file
desc: |
ensure the opened file is closed
do:
- echo "close the file ....."