In this case, the first called sub task - facts will gather the var value of .os and then return its value to caller, then the subsequent call to testingWarning task should print correct os value
tasks:
- name: facts
desc: gather facts
task:
- func: shell
do:
- uname
reg: result
- func: cmd
desc: get os - [Darwin | Linux]
dvars:
- name: os
value: '{{ .result.Output }}'
flags:
- v
do:
- name: print
cmd: 'facts OS: {{.os}}'
- name: return
cmd:
- os
- name: testingWarning
desc: it should warn if the build task is for testing only
task:
- func: block
do:
- func: cmd
do:
- name: print
cmd: 'in sub task - building OS: {{.os}}'
- name: colorPrint
cmd:
msg: ?? WARN - This is a build for testing purpose only
fg: red
if: '{{ eq .os "Darwin" }}'
- name: task
desc: build the showcases automatically
task:
- func: call
do:
- facts
- testingWarning
- func: cmd
do:
- name: print
cmd: 'in main task - building OS: {{.os}}'
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0150
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/c0150
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task3: [task ==> task: build the showcases automatically ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0
})
=Task1: [task ==> facts: gather facts ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 1
})
cmd( 1):
uname
-
Linux
-
.. ok
. ok
--Step2: [: get os - [Darwin | Linux] ]
dvar> os:
"Linux"
-
Linux
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "uname",
Code: 0,
Output: "Linux",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 1,
"result": (*utils.ExecResult)({
Cmd: "uname",
Code: 0,
Output: "Linux",
ErrMsg: ""
}),
"os": "Linux"
})
~~SubStep1: [print: ]
facts OS: Linux
~~SubStep2: [return: ]
=Task2: [task ==> testingWarning: it should warn if the build task is for testing only ]
--Step1:
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "uname",
Code: 0,
Output: "Linux",
ErrMsg: ""
}),
"os": "Linux",
"up_runtime_task_layer_number": 1,
"result": (*utils.ExecResult)({
Cmd: "uname",
Code: 0,
Output: "Linux",
ErrMsg: ""
})
})
condition failed, skip executing step
-Step2:
self: final context exec vars:
(*core.Cache)({
"os": "Linux",
"up_runtime_task_layer_number": 1
})
~SubStep1: [print: ]
in main task - building OS: Linux