Use variables

You can define variables in your UP global context, which means the vars element is a root element of the yml file

In your func implementation(it is a shell in this case), you can reference this var using golang template syntax

Demo

source

Main task yaml file
    vars:
      a: runtime-a
      e: runtime-e
      k: runtime-k
    tasks:
    - name: task
      task:
      - func: shell
        desc: to test display env vars from shell context
        do:
        - echo "hello, world"
        - echo 'hello {{.a}}'
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> c0012
                 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/c0012
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1: [: to test display env vars from shell context ]
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0,
      "e": "runtime-e",
      "k": "runtime-k",
      "a": "runtime-a"
    })
    
    cmd( 1):
    echo "hello, world"
    
    -
    hello, world
    
    -
     .. ok
    cmd( 2):
    echo 'hello {{.a}}'
    
    -
    hello runtime-a
    
    -
     .. ok
    . ok
    
Logs with different verbose level
Raw logs with different verbose level

How it works?

hello {{.a}} will print out the actual value ‘runtime-a’

Prerequisites

Understanding of basics usage of golang template