Skip to main content

$env

The $env built-in service provides access to environment variables added within the project and includes only one method: get.

$env.get​

This method looks up and returns the value of a variable with the specified name.

Syntax​

The method accepts the following string arguments:

  • name is a name of the variable the method will look for in the list of variables.
  • defaultValue is a value the method will return if the variable with the specified name is not found.
caution
If you do not specify defaultValue and the required variable is not found, an error will be raised in the script.

Example​

An example of calling the method:

$env.get("myVariable", "Variable not found")

If the myVariable variable exists in the project, the method will return its value. Otherwise, the method will return Variable not found.