Environment Variables

Environment Variables#

environment variable#

Environment variables are usually used to define the context of a computer process. They are defined by a variable name and a value. These environment variables are then made available to a computer process.

In Yaku, especially in the qg-config.yaml file, environment variables can be used to alter the way how a certain autopilot script behaves.

While environment variables usually define the environment in which a particular process runs, they can be defined and used in many different places inside a QG config file, not just close to the script in which they are used.

Autopilot Parameters#

The most common use is to provide parameters to an autopilot by specifying some environment variables in the env section of an autopilot definition, or in the global env section, e.g.

Example of global and local environment variables in autopilots#
env:
  GLOBAL_VAR: World

autopilots:
  # This autopilot prints "Hello World"
  hello-world-autopilot:
    run: |
      echo "${{ env.LOCAL_VAR }} ${{ env.GLOBAL_VAR }}"
    env:
      LOCAL_VAR: Hello

  # This autopilot prints "Goodbye World"
  goodbye-world-autopilot:
    run: |
      echo "${{ env.LOCAL_VAR }} ${{ env.GLOBAL_VAR }}"
    env:
      LOCAL_VAR: Goodbye

Note

You can find a list of environment variables for the different autopilot apps on the Index page.

Secrets#

Another example is the use of environment variables for secrets, for example when an autopilot requires sensitive data like login credentials.

Warning

You should never store passwords, tokens, or other credentials in the config file. Instead, store those credentials always as secrets!

Most programs and apps will read credentials only from environment variables and not from command line arguments. For this, you can reference the secret in the environment variable definition:

my-sensitive-autopilot:
  run: |
    download-something  # uses MY_SECRET internally by reading the environment variable
  env:
    MY_SECRET: ${{ secrets.SECRET_NAME }}  # as defined in the secret store

For more information on secrets, see Creating secrets and Using secrets.

Advanced Topics#