Custom Command template context
Last updated
Last updated
The below keys are available in template strings for the exec
and gardenCommand
fields in Custom Commands.
${local.*}
Context variables that are specific to the currently running environment/machine.
Type |
---|
${local.artifactsPath}
The absolute path to the directory where exported artifacts from test and task runs are stored.
Type |
---|
Example:
${local.env.*}
A map of all local environment variables (see https://nodejs.org/api/process.html#process_process_env).
Type |
---|
${local.env.<env-var-name>}
The environment variable value.
Type |
---|
${local.arch}
A string indicating the architecture that the framework is running on (see https://nodejs.org/api/process.html#process_process_arch)
Example:
${local.platform}
A string indicating the platform that the framework is running on (see https://nodejs.org/api/process.html#process_process_platform)
Example:
${local.projectPath}
The absolute path to the project root directory.
Example:
${local.username}
The current username (as resolved by https://github.com/sindresorhus/username).
Example:
${local.usernameLowerCase}
The current username (as resolved by https://github.com/sindresorhus/username), with any upper case characters converted to lower case.
Example:
${command.*}
Information about the currently running command and its arguments.
${command.name}
The currently running Garden CLI command, without positional arguments or option flags. This can be handy to e.g. change some variables based on whether you're running garden test
or some other specific command.
Note that this will currently always resolve to "workflow"
when running Workflows, as opposed to individual workflow step commands. This may be revisited at a later time, but currently all configuration is resolved once for all workflow steps.
Example:
${command.params.*}
A map of all parameters set when calling the current command. This includes both positional arguments and option flags, and includes any default values set by the framework or specific command. This can be powerful if used right, but do take care since different parameters are only available in certain commands, some have array values etc.
Option values can be referenced by the option's default name (e.g. local-mode
) or its alias (e.g. local
) if one is defined for that option.
${command.params.<name>}
${datetime.*}
Information about the date/time at template resolution time.
${datetime.now}
The current UTC date and time, at time of template resolution, in ISO-8601 format.
Example:
${datetime.today}
The current UTC date, at time of template resolution, in ISO-8601 format.
Example:
${datetime.timestamp}
The current UTC Unix timestamp (in seconds), at time of template resolution.
Example:
${project.*}
Information about the Garden project.
${project.name}
The name of the Garden project.
Example:
${git.*}
Information about the current state of the project's Git repository.
${git.branch}
The current Git branch, if available. Resolves to an empty string if HEAD is in a detached state (e.g. when rebasing), or if the repository has no commits.
When using remote sources, the branch used is that of the project/top-level repository (the one that contains the project configuration).
The branch is resolved at the start of the Garden command's execution, and is not updated if the current branch changes during the command's execution (which could happen, for example, when using watch-mode commands).
Example:
${git.commitHash}
The current Git commit hash, if available. Resolves to an empty string if the repository has no commits.
When using remote sources, the hash used is that of the project/top-level repository (the one that contains the project configuration).
The hash is resolved at the start of the Garden command's execution, and is not updated if the current commit changes during the command's execution (which could happen, for example, when using watch-mode commands).
Example:
${git.originUrl}
The remote origin URL of the project Git repository.
When using remote sources, the URL is that of the project/top-level repository (the one that contains the project configuration).
Example:
${variables.*}
A map of all variables defined in the command configuration.
${variables.<variable-name>}
${var.*}
Alias for the variables field.
${var.<name>}
Number, string or boolean
${args.*}
Map of all arguments, as defined in the Command spec. Also includes $all
, $rest
and --
fields. See their description for details.
${args.$all[]}
Every argument passed to the command, except the name of the command itself.
${args.$rest[]}
Every positional argument and option that isn't explicitly defined in the custom command, including any global Garden flags.
${args.--[]}
Every argument following -- on the command line.
${args.<name>}
Number, string or boolean
${opts.*}
Map of all options, as defined in the Command spec.
${opts.<name>}
Number, string or boolean
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type |
---|
Type | Default |
---|---|
Type |
---|
Type | Default |
---|---|
Type |
---|
Type | Default |
---|---|
Type | Default |
---|---|
Type | Default |
---|---|
Type | Default |
---|---|
Type |
---|
Type | Default |
---|---|
Type |
---|
object
string
object
string
string
string
string
string
string
object
string
object
any
object
string
string
string
object
string
object
string
string
string
object
{}
string | number | boolean | link | array[link]
object
{}
string | number | boolean
object
{}
array[string]
[]
array[string]
[]
array[string]
[]
string | number | boolean
object
{}
string | number | boolean