-
Notifications
You must be signed in to change notification settings - Fork 4
/
c0013.yml
87 lines (72 loc) · 2.21 KB
/
c0013.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: vars
title: vars in func
head: |
The vars definition block in a func(shell in this case) make the vars' scope to be local scope to the func, the var defined in the local scope is only available in all the execution steps in that func
It is similar to func or method in most of programming languages, the vars defined in local scope in func are only avaiable in local scope callee task is reprented using a var name make it dynamic in execution time
sections:
- title: Glabal vars
content: |
The global vasrs are the one defined externally to the tasks definition, eg:
```
vars:
a: runtime-a
e: runtime-e
k: runtime-k
studentname: Jason
```
- title: Local vars
content: |
The local vasrs are the one defined within the func definition, eg:
```
vars:
studentname: Tom
school: SG
```
- title: Auto merge
content: |
During the runtime of step1, it will merge the vars with the same name, the local vars take priority. In this demo, the var studentname will be Tom instead of Jason
- title: Demo
log: yes
- title: What to observe in log file
content: |
do check the verbosed log in vvv level, you will see that studentname exist only in local var scope, which are the final exec vars
```
-------runtime global final merged with dvars-------
{
"k": "runtime-k",
"studentname": "Jason",
"a": "runtime-a",
"e": "runtime-e"
}
overall final exec vars:
{
"a": "runtime-a",
"e": "runtime-e",
"school": "SG",
"k": "runtime-k",
"studentname": "Tom"
}
```
notes:
goal:
- to test vars without scope will still work
vars:
a: runtime-a
e: runtime-e
k: runtime-k
studentname: Jason
tasks:
-
name: task
task:
-
func: shell
name: step1
desc: to test display env vars from shell context
vars:
studentname: Tom
school: SG
do:
- echo "hello, world"
- echo "hello {{.studentname}}"