-
-
Notifications
You must be signed in to change notification settings - Fork 780
Closed
Labels
area: loopsChanges related to looping over tasks/commands.Changes related to looping over tasks/commands.
Description
Description
When using for loop with a variable defined in an included Taskfile, the variable is empty/not accessible. This applies to complex variables (list of objects).
Taskfile.yml
`version: "3"
includes:
proc: ./proc_task.yml
tasks:
features-sample-run:
for:
var: PROCESS_FEATURES
cmd: |
echo "Processing feature {{.ITEM.id}}"
{{if .ITEM.macros}}echo " Macros: {{.ITEM.macros}}"{{end}}`
proc_task.yml
`version: "3"
vars:
PROCESS_FEATURES:
- id: 1
- id: 2
macros: -DUW_RINGBUF
- id: 3
macros: -DUW_RINGBUF -DUW_FENTRY
Output
$ task features-sample-run
task: [features-sample-run] echo "Processing feature "
Processing feature
Expected behavior
The for loop should iterate over the PROCESS_FEATURES list and output:
Processing feature 1
Processing feature 2
Macros: -DUW_RINGBUF
Processing feature 3
Macros: -DUW_RINGBUF -DUW_FENTRY
What I tried
for: { var: PROCESS_FEATURES }— emptyfor: { var: proc.PROCESS_FEATURES }— empty- Using
vars: FEATURES: '{{.proc.PROCESS_FEATURES}}'thenfor: { var: FEATURES }— empty
Related issues
- Variables from included Taskfiles cannot be overwritten #2108 — Variables from included Taskfiles cannot be overwritten (fix was reverted)
- Discussion Variables in included Taskfiles leak to parent Taskfile #2488 — Variables in included Taskfiles leak to parent Taskfile
Version
$ task --version
Metadata
Metadata
Assignees
Labels
area: loopsChanges related to looping over tasks/commands.Changes related to looping over tasks/commands.