-
-
Notifications
You must be signed in to change notification settings - Fork 704
Open
Labels
state: needs triageWaiting to be triaged by a maintainer.Waiting to be triaged by a maintainer.
Description
What did I do?
While writing a task file, I wanted to have a variable A
having a value depending on the value of another B
that could be passed by the user when calling the task.
I wanted to have a third variable C
to use to use the resulting value of A
.
The whole taskfile is then imported in another one.
What happened?
Depending on the position of B
in the command line, C
would be evaluated twice with two different values of A
.
This only occurs if the first example.
First example:
included.yml
version: '3.41'
vars:
A: '{{.B | default (.A | default "nope")}}'
C:
sh: echo {{.A}}
tasks:
test: echo {{.C}}
task.yml
version: '3.41'
includes:
fail:
taskfile: ./include.yml
Execution:
# executed two times
$ task fail:test -v B=two
task: [/home/mpeim.linux/debug-taskfiles] Not found - Using alternative (taskfile.yml)
task: dynamic variable: "echo nope" result: "nope"
task: dynamic variable: "echo two" result: "two"
task: "fail:test" started
task: [fail:test] echo "two"
two
task: "fail:test" finished
$ B=one task fail:test -v
task: [/home/mpeim.linux/debug-taskfiles] Not found - Using alternative (taskfile.yml)
task: dynamic variable: "echo one" result: "one"
task: "fail:test" started
task: [fail:test] echo "one"
one
task: "fail:test" finished
Second example:
include.yml stays the same.
taskfile.yml
version: '3.41'
# note that the field `taskfile` is not given
includes:
fail: ./include.yml
Execution:
$ task fail:test -v B=yup
task: [/home/mpeim.linux/debug-taskfiles] Not found - Using alternative (taskfile.yml)
task: dynamic variable: "echo nope" result: "nope"
task: "fail:test" started
task: [fail:test] echo "nope"
nope
task: "fail:test" finished
$ B=one task fail:test -v
task: [/home/mpeim.linux/debug-taskfiles] Not found - Using alternative (taskfile.yml)
task: dynamic variable: "echo one" result: "one"
task: "fail:test" started
task: [fail:test] echo "one"
one
task: "fail:test" finished
Expectated behavior
I would expect the dynamic variable to be executed once in every case.
Version
3.41
Operating system
Linux lima-vpp3 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:36 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
Experiments Enabled
With and without TASK_X_MAP_VARIABLES=1
Metadata
Metadata
Assignees
Labels
state: needs triageWaiting to be triaged by a maintainer.Waiting to be triaged by a maintainer.