$secrets
The $secrets
built-in service provides access to secrets added within the project and includes only one method: get
.
$secrets.get
This method looks up and returns the value of a secret with the specified name.
Syntax
The method accepts the following string arguments:
name
is a name of the secret the method will look for in the list of secrets.defaultValue
is a value the method will return if the secret with the specified name is not found.
caution
If you do not specify
defaultValue
and the required secret is not found, an error will be raised in the script.Example
An example of calling the method:
$secrets.get("mySecret", "Default token value")
If the mySecret
secret exists in the project, the method will return its value.
Otherwise, the method will return Default token value
.