This makes the environment variables’ management very elegant and tidy. Not only you could use dvar to manage dynamic properties, but also you could manage environment variable the same way and a set of env vars could be put into a profile for an environment context. This is important nowadays for CD/CI and integration automation with build tools as envionrment variables are normally the client facing to these tools, such as GoCD, Jenkins, Gitlab CI etc.
scopes:
- name: global
dvars:
- name: SCHOOL
value: James Rules
flags: [envVar]
dvars:
- name: STUDENT_NAME
value: James Bond
flags: [envVar]
- name: STUDENT_AGE
value: "18"
flags: [envVar]
tasks:
- name: task
task:
- func: shell
dvars:
- name: STUDENT_NAME
value: Tom Hanks
flags: [envVar]
do:
- env |grep STUDENT_NAME
- env |grep STUDENT_AGE
- func: shell
desc: |
since there is no local envVar for STUDENT_NAME
it should use global envVar value 'james bond'
do:
- env |grep STUDENT_NAME
- env |grep STUDENT_AGE
- env |grep SCHOOL
loading [Config]: ./tests/functests/upconfig.yml
Main config:
Version -> 1.0.0
RefDir -> ./tests/functests
WorkDir -> cwd
AbsWorkDir -> /up_project/up
TaskFile -> c0049
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/c0049
module: [self], instance id: [dev], exec profile: []
profile - envVars:
(*core.Cache)({
})
Task1: [task ==> task: ]
-Step1:
self: final context exec vars:
(*core.Cache)({
"STUDENT_AGE": "18",
"SCHOOL": "James Rules",
"up_runtime_task_layer_number": 0,
"envVar_SCHOOL": "James Rules",
"envVar_STUDENT_AGE": "18",
"STUDENT_NAME": "Tom Hanks",
"envVar_STUDENT_NAME": "Tom Hanks"
})
cmd( 1):
env |grep STUDENT_NAME
-
STUDENT_NAME=Tom Hanks
-
.. ok
cmd( 2):
env |grep STUDENT_AGE
-
STUDENT_AGE=18
-
.. ok
. ok
-Step2: [
since there is no local envVar for STUDENT_NAME
it should use global envVar value 'james bond'
]
self: final context exec vars:
(*core.Cache)({
"envVar_STUDENT_AGE": "18",
"STUDENT_NAME": "James Bond",
"envVar_STUDENT_NAME": "James Bond",
"STUDENT_AGE": "18",
"last_result": (*utils.ExecResult)({
Cmd: "env |grep STUDENT_AGE",
Code: 0,
Output: "STUDENT_AGE=18",
ErrMsg: ""
}),
"SCHOOL": "James Rules",
"up_runtime_task_layer_number": 0,
"envVar_SCHOOL": "James Rules"
})
cmd( 1):
env |grep STUDENT_NAME
-
STUDENT_NAME=James Bond
-
.. ok
cmd( 2):
env |grep STUDENT_AGE
-
STUDENT_AGE=18
-
.. ok
cmd( 3):
env |grep SCHOOL
-
SCHOOL=James Rules
-
.. ok
. ok