github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0049.yml (about) 1 doc_meta: | 2 folder: env-vars 3 title: env vars in scopes 4 head: | 5 This showcases: 6 * The env var using dvar will be just like other dvar working in scopes 7 8 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. 9 10 sections: 11 - title: Demo 12 log: yes 13 14 notes: 15 goal: 16 - test the shell env var behaves the save that it could override in scopes 17 18 results: | 19 executing shell commands 20 cmd( 1): 21 env |grep STUDENT_NAME 22 STUDENT_NAME=Tom Hanks 23 cmd( 2): 24 env |grep STUDENT_AGE 25 STUDENT_AGE=18 26 step( 2): 27 executing shell commands 28 cmd( 1): 29 env |grep STUDENT_NAME 30 STUDENT_NAME=James Bond 31 cmd( 2): 32 env |grep STUDENT_AGE 33 STUDENT_AGE=18 34 cmd( 3): 35 env |grep SCHOOL 36 SCHOOL=James Rules 37 38 scopes: 39 - name: global 40 dvars: 41 - name: SCHOOL 42 value: James Rules 43 flags: [envVar] 44 45 dvars: 46 - name: STUDENT_NAME 47 value: James Bond 48 flags: [envVar] 49 50 - name: STUDENT_AGE 51 value: "18" 52 flags: [envVar] 53 54 tasks: 55 56 - 57 name: task 58 task: 59 - func: shell 60 dvars: 61 - name: STUDENT_NAME 62 value: Tom Hanks 63 flags: [envVar] 64 do: 65 - env |grep STUDENT_NAME 66 - env |grep STUDENT_AGE 67 68 - func: shell 69 desc: | 70 since there is no local envVar for STUDENT_NAME 71 it should use global envVar value 'james bond' 72 do: 73 - env |grep STUDENT_NAME 74 - env |grep STUDENT_AGE 75 - env |grep SCHOOL