Function: sys.get_env

Retrieves the value of the specified environment variable.

If the specified variable is not set, returns the default value instead.

The following built-in environment variables are supported:

Variable nameDescription
GOOGLE_CLOUD_LOCATIONThe workflow's location.
GOOGLE_CLOUD_PROJECT_IDThe workflow project's identifier.
GOOGLE_CLOUD_PROJECT_NUMBERThe workflow project's number.
GOOGLE_CLOUD_SERVICE_ACCOUNT_NAMEThe workflow execution's service
account name.
GOOGLE_CLOUD_WORKFLOW_EXECUTION_IDThe workflow execution's identifier.
GOOGLE_CLOUD_WORKFLOW_IDThe workflow's identifier.
GOOGLE_CLOUD_WORKFLOW_REVISION_IDThe workflow's revision identifier.

You can also retrieve user-defined environment variables. For moreinformation, seeUse environment variables.

Arguments

Arguments
name

string

The requested environment variable name.

default

string

The string value to return if the named variable is not set.

Returns

The value of the named environment variable, or the default if not set.

Raised exceptions

Exceptions
TypeErrorIf eithername ordefault is not a string.

Examples

For more information, seeBuilt-in environment variables

# Retrieve value of specified environment variable# For example, returns "us-central1"-returnStep:return:${sys.get_env("GOOGLE_CLOUD_LOCATION")}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.