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
| Argument | Required | Description |
|---|---|---|
key | Yes | Environment variable name to read. |
deps | No | Dependencies 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)