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
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
The local vasrs are the one defined within the func definition, eg:
vars:
studentname: Tom
school: SG
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
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}}"
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0013
Verbose -> vvv
ModuleName -> self
ShellType -> /bin/sh
MaxCallLayers -> 8
Timeout -> 3600000
MaxModuelCallLayers -> 256
EntryTask -> task
ModRepoUsernameRef ->
ModRepoPasswordRef ->
work dir: /up_project/up
-exec task: task
loading [Task]: ./tests/functests/c0013
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1: [step1: to test display env vars from shell context ]
self: final context exec vars:
(*core.Cache)({
"school": "SG",
"a": "runtime-a",
"e": "runtime-e",
"k": "runtime-k",
"studentname": "Tom",
"up_runtime_task_layer_number": 0
})
cmd( 1):
echo "hello, world"
-
hello, world
-
.. ok
cmd( 2):
echo "hello {{.studentname}}"
-
hello Tom
-
.. ok
. ok
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"
}