A shell func is a func implementation, in which you could add one or multiple line of shell scripts to be executed
We will call the step in the array of steps shell func as sub step to just avoid confusion, each func implementation in a task is called a step
A flag in flag list attaching to a func dictates some behavior, in such a way it provides additional feature to the execution, workflow etc
Normally a successful shell execution returns exit code 0, ignoreError is to allow the executio to contiue to next or end without a return code of 0
In this demo, it reports the sub step has failed with its own return code, but it continue to complete all execution
tasks:
- name: task
desc: this is task
task:
- func: shell
desc: do step1 in shell func
do:
- echo "hello"
- echo "world"
- func: shell
desc: do step2 in shell func
flags:
- ignoreError
do:
- echo "hello"
- echo "I got exception"|grep non-exist
- echo "world"
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0002
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/c0002
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: this is task ]
-Step1: [: do step1 in shell func ]
self: final context exec vars:
(*core.Cache)({
"up_runtime_task_layer_number": 0
})
cmd( 1):
echo "hello"
-
hello
-
.. ok
cmd( 2):
echo "world"
-
world
-
.. ok
. ok
-Step2: [: do step2 in shell func ]
self: final context exec vars:
(*core.Cache)({
"last_result": (*utils.ExecResult)({
Cmd: "echo \"world\"",
Code: 0,
Output: "world",
ErrMsg: ""
}),
"up_runtime_task_layer_number": 0
})
cmd( 1):
echo "hello"
-
hello
-
.. ok
cmd( 2):
echo "I got exception"|grep non-exist
-
-
.. failed(suppressed if it is not the last step)
cmd( 3):
echo "world"
-
world
-
.. ok
. ok