-
-
Notifications
You must be signed in to change notification settings - Fork 747
Description
Description
The documentation states that in order to overwrite a variable from an included Taskfile, one has to use the syntax
MY_VAR: '{{.MY_VAR | default "my-default-value"}}'
That does not work, at least not for 'global' variables defined in the top-level vars
field of the Taskfile.
Taskfile.yaml
version: 3
vars:
FOOBAR: foo
includes:
bar: Taskfile_bar.yaml
tasks:
foobar:
cmds:
- cmd: echo '{{.FOOBAR}}'
silent: true
Taskfile_bar.yaml
version: 3
vars:
FOOBAR: '{{.FOOBAR | default "bar"}}'
tasks:
foobar:
cmds:
- cmd: echo '{{.FOOBAR}}'
silent: true
The Problem
Running either task foobar
or task bar:foobar
results in bar
, but both should print foo
instead.
I have to admit that I find the behavior weird in general, I would assume that in most use-cases, variables from the imported Taskfile (often generic/library) should be overwritten by the ones from the importing Taskfile (specialized for project). Having it work the other way around is somewhat confusing. I can work with that though, but if there is no way to overwrite the variables in the included Taskfile from the including one, that is a problem.
Version
v3.41.0
Operating system
darwin/arm64
Experiments Enabled
None