xx
.md

env_get

env_get reads an environment variable while the Starlark file is evaluated. It returns a string when the variable exists and None when it does not. Reading a value does not modify the base environment or any task.

Arguments

ArgumentRequiredDescription
keyYesEnvironment variable name to read.
depsNoDependencies applied to an environment clone before reading. Defaults to [].

Examples

Read a base value

load("@os@1", "env_get")

system_path = env_get("PATH")

Read a composed environment

load("@os@1", "env_get", "env_set")

go_flags = env_get(
    "GOFLAGS",
    deps=[env_set("GOFLAGS", "-trimpath")],
)

print(go_flags)