exec

Description

A simple module for executing commands in your shell. This can be a useful escape hatch if no other module type fits your needs, and you just need to execute something (as opposed to deploy it, track its status etc.).
By default, the exec module type executes the commands in the Garden build directory (under .garden/build/). By setting local: true, the commands are executed in the module source directory instead.
Note that Garden does not sync the source code for local exec modules into the Garden build directory. This means that include/exclude filters and ignore files are not applied to local exec modules, as the filtering is done during the sync.
Below is the full schema reference. For an introduction to configuring Garden modules, please look at our Configuration guide.
The first section contains the complete YAML schema, and the second section describes each schema key.
exec modules also export values that are available in template strings. See the Outputs section below for details.

Complete YAML Schema

The values in the schema below are the default values.
1
# The schema version of this config (currently not used).
2
apiVersion: garden.io/v0
3
​
4
kind: Module
5
​
6
# The type of this module.
7
type:
8
​
9
# The name of this module.
10
name:
11
​
12
# Specify how to build the module. Note that plugins may define additional keys on this object.
13
build:
14
# A list of modules that must be built before this module is built.
15
dependencies:
16
- # Module name to build ahead of this module.
17
name:
18
​
19
# Specify one or more files or directories to copy from the built dependency to this module.
20
copy:
21
- # POSIX-style path or filename of the directory or file(s) to copy to the target.
22
source:
23
​
24
# POSIX-style path or filename to copy the directory or file(s), relative to the build directory.
25
# Defaults to to same as source path.
26
target: ''
27
​
28
# Maximum time in seconds to wait for build to finish.
29
timeout: 1200
30
​
31
# The command to run to perform the build.
32
#
33
# By default, the command is run inside the Garden build directory (under .garden/build/<module-name>).
34
# If the top level `local` directive is set to `true`, the command runs in the module source directory instead.
35
command: []
36
​
37
# A description of the module.
38
description:
39
​
40
# Set this to `true` to disable the module. You can use this with conditional template strings to disable modules
41
# based on, for example, the current environment or other variables (e.g. `disabled: \${environment.name == "prod"}`).
42
# This can be handy when you only need certain modules for specific environments, e.g. only for development.
43
#
44
# Disabling a module means that any services, tasks and tests contained in it will not be deployed or run. It also
45
# means that the module is not built _unless_ it is declared as a build dependency by another enabled module (in which
46
# case building this module is necessary for the dependant to be built).
47
#
48
# If you disable the module, and its services, tasks or tests are referenced as _runtime_ dependencies, Garden will
49
# automatically ignore those dependency declarations. Note however that template strings referencing the module's
50
# service or task outputs (i.e. runtime outputs) will fail to resolve when the module is disabled, so you need to make
51
# sure to provide alternate values for those if you're using them, using conditional expressions.
52
disabled: false
53
​
54
# Specify a list of POSIX-style paths or globs that should be regarded as the source files for this module. Files that
55
# do *not* match these paths or globs are excluded when computing the version of the module, when responding to
56
# filesystem watch events, and when staging builds.
57
#
58
# Note that you can also _exclude_ files using the `exclude` field or by placing `.gardenignore` files in your source
59
# tree, which use the same format as `.gitignore` files. See the [Configuration Files
60
# guide](https://docs.garden.io/using-garden/configuration-overview#including-excluding-files-and-directories) for
61
# details.
62
#
63
# Also note that specifying an empty list here means _no sources_ should be included.
64
include:
65
​
66
# Specify a list of POSIX-style paths or glob patterns that should be excluded from the module. Files that match these
67
# paths or globs are excluded when computing the version of the module, when responding to filesystem watch events,
68
# and when staging builds.
69
#
70
# Note that you can also explicitly _include_ files using the `include` field. If you also specify the `include`
71
# field, the files/patterns specified here are filtered from the files matched by `include`. See the [Configuration
72
# Files guide](https://docs.garden.io/using-garden/configuration-overview#including-excluding-files-and-directories)
73
# for details.
74
#
75
# Unlike the `modules.exclude` field in the project config, the filters here have _no effect_ on which files and
76
# directories are watched for changes. Use the project `modules.exclude` field to affect those, if you have large
77
# directories that should not be watched for changes.
78
exclude:
79
​
80
# A remote repository URL. Currently only supports git servers. Must contain a hash suffix pointing to a specific
81
# branch or tag, with the format: <git remote url>#<branch|tag>
82
#
83
# Garden will import the repository source code into this module, but read the module's config from the local
84
# garden.yml file.
85
repositoryUrl:
86
​
87
# When false, disables pushing this module to remote registries.
88
allowPublish: true
89
​
90
# A list of files to write to the module directory when resolving this module. This is useful to automatically
91
# generate (and template) any supporting files needed for the module.
92
generateFiles:
93
- # POSIX-style filename to read the source file contents from, relative to the path of the module (or the
94
# ModuleTemplate configuration file if one is being applied).
95
# This file may contain template strings, much like any other field in the configuration.
96
sourcePath:
97
​
98
# POSIX-style filename to write the resolved file contents to, relative to the path of the module source directory
99
# (for remote modules this means the root of the module repository, otherwise the directory of the module
100
# configuration).
101
#
102
# Note that any existing file with the same name will be overwritten. If the path contains one or more
103
# directories, they will be automatically created if missing.
104
targetPath:
105
​
106
# By default, Garden will attempt to resolve any Garden template strings in source files. Set this to false to
107
# skip resolving template strings. Note that this does not apply when setting the `value` field, since that's
108
# resolved earlier when parsing the configuration.
109
resolveTemplates: true
110
​
111
# The desired file contents as a string.
112
value:
113
​
114
# A map of variables scoped to this particular module. These are resolved before any other parts of the module
115
# configuration and take precedence over project-scoped variables. They may reference project-scoped variables, and
116
# generally use any template strings normally allowed when resolving modules.
117
variables:
118
​
119
# If set to true, Garden will run the build command, services, tests, and tasks in the module source directory,
120
# instead of in the Garden build directory (under .garden/build/<module-name>).
121
#
122
# Garden will therefore not stage the build for local exec modules. This means that include/exclude filters
123
# and ignore files are not applied to local exec modules.
124
local: false
125
​
126
# Key/value map of environment variables. Keys must be valid POSIX environment variable names (must not start with
127
# `GARDEN`) and values must be primitives.
128
env: {}
129
​
130
# A list of services to deploy from this module.
131
services:
132
- # Valid RFC1035/RFC1123 (DNS) label (may contain lowercase letters, numbers and dashes, must start with a letter,
133
# and cannot end with a dash), cannot contain consecutive dashes or start with `garden`, or be longer than 63
134
# characters.
135
name:
136
​
137
# The names of any services that this service depends on at runtime, and the names of any tasks that should be
138
# executed before this service is deployed.
139
dependencies: []
140
​
141
# Set this to `true` to disable the service. You can use this with conditional template strings to enable/disable
142
# services based on, for example, the current environment or other variables (e.g. `enabled: \${environment.name
143
# != "prod"}`). This can be handy when you only need certain services for specific environments, e.g. only for
144
# development.
145
#
146
# Disabling a service means that it will not be deployed, and will also be ignored if it is declared as a runtime
147
# dependency for another service, test or task.
148
#
149
# Note however that template strings referencing the service's outputs (i.e. runtime outputs) will fail to resolve
150
# when the service is disabled, so you need to make sure to provide alternate values for those if you're using
151
# them, using conditional expressions.
152
disabled: false
153
​
154
# The command to run to deploy the service.
155
#
156
# By default, the command is run inside the Garden build directory (under .garden/build/<module-name>).
157
# If the top level `local` directive is set to `true`, the command runs in the module source directory instead.
158
deployCommand:
159
​
160
# Optionally set a command to check the status of the service. If this is specified, it is run before the
161
# `deployCommand`. If the command runs successfully and returns exit code of 0, the service is considered
162
# already deployed and the `deployCommand` is not run.
163
#
164
# If this is not specified, the service is always reported as "unknown", so it's highly recommended to specify
165
# this command if possible.
166
#
167
# By default, the command is run inside the Garden build directory (under .garden/build/<module-name>).
168
# If the top level `local` directive is set to `true`, the command runs in the module source directory instead.
169
statusCommand:
170
​
171
# Optionally set a command to clean the service up, e.g. when running `garden delete env`.
172
#
173
# By default, the command is run inside the Garden build directory (under .garden/build/<module-name>).
174
# If the top level `local` directive is set to `true`, the command runs in the module source directory instead.
175
cleanupCommand:
176
​
177
# Environment variables to set when running the deploy and status commands.
178
env: {}
179
​
180
# A list of tasks that can be run in this module.
181
tasks:
182
- # The name of the task.
183
name:
184
​
185
# A description of the task.
186
description:
187
​
188
# The names of any tasks that must be executed, and the names of any services that must be running, before this
189
# task is executed.
190
dependencies: []
191
​
192
# Set this to `true` to disable the task. You can use this with conditional template strings to enable/disable
193
# tasks based on, for example, the current environment or other variables (e.g. `enabled: \${environment.name !=
194
# "prod"}`). This can be handy when you only want certain tasks to run in specific environments, e.g. only for
195
# development.
196
#
197
# Disabling a task means that it will not be run, and will also be ignored if it is declared as a runtime
198
# dependency for another service, test or task.
199
#
200
# Note however that template strings referencing the task's outputs (i.e. runtime outputs) will fail to resolve
201
# when the task is disabled, so you need to make sure to provide alternate values for those if you're using them,
202
# using conditional expressions.
203
disabled: false
204
​
205
# Maximum duration (in seconds) of the task's execution.
206
timeout: null
207
​
208
# A list of artifacts to copy after the task run.
209
artifacts:
210
- # A POSIX-style path or glob to copy, relative to the build root.
211
source:
212
​
213
# A POSIX-style path to copy the artifacts to, relative to the project artifacts directory at
214
# `.garden/artifacts`.
215
target: .
216
​
217
# The command to run.
218
#
219
# By default, the command is run inside the Garden build directory (under .garden/build/<module-name>).
220
# If the top level `local` directive is set to `true`, the command runs in the module source directory instead.
221
command:
222
​
223
# Environment variables to set when running the command.
224
env: {}
225
​
226
# A list of tests to run in the module.
227
tests:
228
- # The name of the test.
229
name:
230
​
231
# The names of any services that must be running, and the names of any tasks that must be executed, before the
232
# test is run.
233
dependencies: []
234
​
235
# Set this to `true` to disable the test. You can use this with conditional template strings to
236
# enable/disable tests based on, for example, the current environment or other variables (e.g.
237
# `enabled: \${environment.name != "prod"}`). This is handy when you only want certain tests to run in
238
# specific environments, e.g. only during CI.
239
disabled: false
240
​
241
# Maximum duration (in seconds) of the test run.
242
timeout: null
243
​
244
# The command to run to test the module.
245
#
246
# By default, the command is run inside the Garden build directory (under .garden/build/<module-name>).
247
# If the top level `local` directive is set to `true`, the command runs in the module source directory instead.
248
command:
249
​
250
# Environment variables to set when running the command.
251
env: {}
252
​
253
# A list of artifacts to copy after the test run.
254
artifacts:
255
- # A POSIX-style path or glob to copy, relative to the build root.
256
source:
257
​
258
# A POSIX-style path to copy the artifacts to, relative to the project artifacts directory at
259
# `.garden/artifacts`.
260
target: .
Copied!

Configuration Keys

apiVersion

The schema version of this config (currently not used).
Type
Allowed Values
Default
Required
string
"garden.io/v0"
"garden.io/v0"
Yes

kind

Type
Allowed Values
Default
Required
string
"Module"
"Module"
Yes

type

The type of this module.
Type
Required
string
Yes
Example:
1
type: "container"
Copied!

name

The name of this module.
Type
Required
string
Yes
Example:
1
name: "my-sweet-module"
Copied!

build

Specify how to build the module. Note that plugins may define additional keys on this object.
Type
Default
Required
object
{"dependencies":[]}
No

build.dependencies[]

​build > dependencies
A list of modules that must be built before this module is built.
Type
Default
Required
array[object]
[]
No
Example:
1
build:
2
...
3
dependencies:
4
- name: some-other-module-name
Copied!

build.dependencies[].name

​build > dependencies > name
Module name to build ahead of this module.
Type
Required
string
Yes

build.dependencies[].copy[]

​build > dependencies > copy
Specify one or more files or directories to copy from the built dependency to this module.
Type
Default
Required
array[object]
[]
No

build.dependencies[].copy[].source

​build > dependencies > copy > source
POSIX-style path or filename of the directory or file(s) to copy to the target.
Type
Required
posixPath
Yes

build.dependencies[].copy[].target

​build > dependencies > copy > target
POSIX-style path or filename to copy the directory or file(s), relative to the build directory. Defaults to to same as source path.
Type
Default
Required
posixPath
""
No

build.timeout

​build > timeout
Maximum time in seconds to wait for build to finish.
Type
Default
Required
number
1200
No

build.command[]

​build > command
The command to run to perform the build.
By default, the command is run inside the Garden build directory (under .garden/build/). If the top level local directive is set to true, the command runs in the module source directory instead.
Type
Default
Required
array[string]
[]
No
Example:
1
build:
2
...
3
command:
4
- npm
5
- run
6
- build
Copied!

description

A description of the module.
Type
Required
string
No

disabled

Set this to true to disable the module. You can use this with conditional template strings to disable modules based on, for example, the current environment or other variables (e.g. disabled: \${environment.name == "prod"}). This can be handy when you only need certain modules for specific environments, e.g. only for development.
Disabling a module means that any services, tasks and tests contained in it will not be deployed or run. It also means that the module is not built unless it is declared as a build dependency by another enabled module (in which case building this module is necessary for the dependant to be built).
If you disable the module, and its services, tasks or tests are referenced as runtime dependencies, Garden will automatically ignore those dependency declarations. Note however that template strings referencing the module's service or task outputs (i.e. runtime outputs) will fail to resolve when the module is disabled, so you need to make sure to provide alternate values for those if you're using them, using conditional expressions.
Type
Default
Required
boolean
false
No

include[]

Specify a list of POSIX-style paths or globs that should be regarded as the source files for this module. Files that do not match these paths or globs are excluded when computing the version of the module, when responding to filesystem watch events, and when staging builds.
Note that you can also exclude files using the exclude field or by placing .gardenignore files in your source tree, which use the same format as .gitignore files. See the Configuration Files guide for details.
Also note that specifying an empty list here means no sources should be included.
Type
Required
array[posixPath]
No
Example:
1
include:
2
- Dockerfile
3
- my-app.js
Copied!

exclude[]

Specify a list of POSIX-style paths or glob patterns that should be excluded from the module. Files that match these paths or globs are excluded when computing the version of the module, when responding to filesystem watch events, and when staging builds.
Note that you can also explicitly include files using the include field. If you also specify the include field, the files/patterns specified here are filtered from the files matched by include. See the Configuration Files guide for details.
Unlike the modules.exclude field in the project config, the filters here have no effect on which files and directories are watched for changes. Use the project modules.exclude field to affect those, if you have large directories that should not be watched for changes.
Type
Required
array[posixPath]
No
Example:
1
exclude:
2
- tmp/**/*
3
- '*.log'
Copied!

repositoryUrl

A remote repository URL. Currently only supports git servers. Must contain a hash suffix pointing to a specific branch or tag, with the format: #
Garden will import the repository source code into this module, but read the module's config from the local garden.yml file.
Type
Required
​
`gitUrl
string`
No
Example:
1
repositoryUrl: "git+https://github.com/org/repo.git#v2.0"
Copied!

allowPublish

When false, disables pushing this module to remote registries.
Type
Default
Required
boolean
true
No

generateFiles[]

A list of files to write to the module directory when resolving this module. This is useful to automatically generate (and template) any supporting files needed for the module.
Type
Default
Required
array[object]
[]
No

generateFiles[].sourcePath

​generateFiles > sourcePath
POSIX-style filename to read the source file contents from, relative to the path of the module (or the ModuleTemplate configuration file if one is being applied). This file may contain template strings, much like any other field in the configuration.
Type
Required
posixPath
No

generateFiles[].targetPath

​generateFiles > targetPath
POSIX-style filename to write the resolved file contents to, relative to the path of the module source directory (for remote modules this means the root of the module repository, otherwise the directory of the module configuration).
Note that any existing file with the same name will be overwritten. If the path contains one or more directories, they will be automatically created if missing.
Type
Required
posixPath
Yes

generateFiles[].resolveTemplates

​generateFiles > resolveTemplates
By default, Garden will attempt to resolve any Garden template strings in source files. Set this to false to skip resolving template strings. Note that this does not apply when setting the value field, since that's resolved earlier when parsing the configuration.
Type
Default
Required
boolean
true
No

generateFiles[].value

​generateFiles > value
The desired file contents as a string.
Type
Required
string
No

variables

A map of variables scoped to this particular module. These are resolved before any other parts of the module configuration and take precedence over project-scoped variables. They may reference project-scoped variables, and generally use any template strings normally allowed when resolving modules.
Type
Required
object
No

local

If set to true, Garden will run the build command, services, tests, and tasks in the module source directory, instead of in the Garden build directory (under .garden/build/).
Garden will therefore not stage the build for local exec modules. This means that include/exclude filters and ignore files are not applied to local exec modules.
Type
Default
Required
boolean
false
No

env

Key/value map of environment variables. Keys must be valid POSIX environment variable names (must not start with GARDEN) and values must be primitives.
Type
Default
Required
object
{}
No

services[]

A list of services to deploy from this module.
Type
Default
Required
array[object]
[]
No

services[].name

​services > name
Valid RFC1035/RFC1123 (DNS) label (may contain lowercase letters, numbers and dashes, must start with a letter, and cannot end with a dash), cannot contain consecutive dashes or start with garden, or be longer than 63 characters.
Type
Required
string
Yes

services[].dependencies[]

​services > dependencies
The names of any services that this service depends on at runtime, and the names of any tasks that should be executed before this service is deployed.
Type
Default
Required
array[string]
[]
No

services[].disabled

​services > disabled
Set this to true to disable the service. You can use this with conditional template strings to enable/disable services based on, for example, the current environment or other variables (e.g. enabled: \${environment.name != "prod"}). This can be handy when you only need certain services for specific environments, e.g. only for development.
Disabling a service means that it will not be deployed, and will also be ignored if it is declared as a runtime dependency for another service, test or task.
Note however that template strings referencing the service's outputs (i.e. runtime outputs) will fail to resolve when the service is disabled, so you need to make sure to provide alternate values for those if you're using them, using conditional expressions.
Type
Default
Required
boolean
false
No

services[].deployCommand[]

​services > deployCommand
The command to run to deploy the service.
By default, the command is run inside the Garden build directory (under .garden/build/). If the top level local directive is set to true, the command runs in the module source directory instead.
Type
Required
array[string]
Yes

services[].statusCommand[]

​services > statusCommand
Optionally set a command to check the status of the service. If this is specified, it is run before the deployCommand. If the command runs successfully and returns exit code of 0, the service is considered already deployed and the deployCommand is not run.
If this is not specified, the service is always reported as "unknown", so it's highly recommended to specify this command if possible.
By default, the command is run inside the Garden build directory (under .garden/build/). If the top level local directive is set to true, the command runs in the module source directory instead.
Type
Required
array[string]
No

services[].cleanupCommand[]

​services > cleanupCommand
Optionally set a command to clean the service up, e.g. when running garden delete env.
By default, the command is run inside the Garden build directory (under .garden/build/). If the top level local directive is set to true, the command runs in the module source directory instead.
Type
Required
array[string]
No

services[].env

​services > env
Environment variables to set when running the deploy and status commands.
Type
Default
Required
object
{}
No

tasks[]

A list of tasks that can be run in this module.
Type
Default
Required
array[object]
[]
No

tasks[].name

​tasks > name
The name of the task.
Type
Required
string
Yes

tasks[].description

​tasks > description
A description of the task.
Type
Required
string
No

tasks[].dependencies[]

​tasks > dependencies
The names of any tasks that must be executed, and the names of any services that must be running, before this task is executed.
Type
Default
Required
array[string]
[]
No

tasks[].disabled

​tasks > disabled
Set this to true to disable the task. You can use this with conditional template strings to enable/disable tasks based on, for example, the current environment or other variables (e.g. enabled: \${environment.name != "prod"}). This can be handy when you only want certain tasks to run in specific environments, e.g. only for development.
Disabling a task means that it will not be run, and will also be ignored if it is declared as a runtime dependency for another service, test or task.
Note however that template strings referencing the task's outputs (i.e. runtime outputs) will fail to resolve when the task is disabled, so you need to make sure to provide alternate values for those if you're using them, using conditional expressions.
Type
Default
Required
boolean
false
No

tasks[].timeout

​tasks > timeout
Maximum duration (in seconds) of the task's execution.
Type
Default
Required
number
null
No

tasks[].artifacts[]

​tasks > artifacts
A list of artifacts to copy after the task run.
Type
Default
Required
array[object]
[]
No

tasks[].artifacts[].source

​tasks > artifacts > source
A POSIX-style path or glob to copy, relative to the build root.
Type
Required
posixPath
Yes

tasks[].artifacts[].target

​tasks > artifacts > target
A POSIX-style path to copy the artifacts to, relative to the project artifacts directory at .garden/artifacts.
Type
Default
Required
posixPath
"."
No

tasks[].command[]

​tasks > command
The command to run.
By default, the command is run inside the Garden build directory (under .garden/build/). If the top level local directive is set to true, the command runs in the module source directory instead.
Type
Required
array[string]
Yes

tasks[].env

​tasks > env
Environment variables to set when running the command.
Type
Default
Required
object
{}
No

tests[]

A list of tests to run in the module.
Type
Default
Required
array[object]
[]
No

tests[].name

​tests > name
The name of the test.
Type
Required
string
Yes

tests[].dependencies[]

​tests > dependencies
The names of any services that must be running, and the names of any tasks that must be executed, before the test is run.
Type
Default
Required
array[string]
[]
No

tests[].disabled

​tests > disabled
Set this to true to disable the test. You can use this with conditional template strings to enable/disable tests based on, for example, the current environment or other variables (e.g. enabled: \${environment.name != "prod"}). This is handy when you only want certain tests to run in specific environments, e.g. only during CI.
Type
Default
Required
boolean
false
No

tests[].timeout

​tests > timeout
Maximum duration (in seconds) of the test run.
Type
Default
Required
number
null
No

tests[].command[]

​tests > command
The command to run to test the module.
By default, the command is run inside the Garden build directory (under .garden/build/). If the top level local directive is set to true, the command runs in the module source directory instead.
Type
Required
array[string]
Yes

tests[].env

​tests > env
Environment variables to set when running the command.
Type
Default
Required
object
{}
No

tests[].artifacts[]

​tests > artifacts
A list of artifacts to copy after the test run.
Type
Default
Required
array[object]
[]
No

tests[].artifacts[].source

​tests > artifacts > source
A POSIX-style path or glob to copy, relative to the build root.
Type
Required
posixPath
Yes

tests[].artifacts[].target

​tests > artifacts > target
A POSIX-style path to copy the artifacts to, relative to the project artifacts directory at .garden/artifacts.
Type
Default
Required
posixPath
"."
No

Outputs

Module Outputs

The following keys are available via the ${modules.<module-name>} template string key for exec modules.

${modules.<module-name>.buildPath}

The build path of the module.
Type
string
Example:
1
my-variable: ${modules.my-module.buildPath}
Copied!

${modules.<module-name>.name}

The name of the module.
Type
string

${modules.<module-name>.path}

The local path of the module.
Type
string
Example:
1
my-variable: