task icon indicating copy to clipboard operation
task copied to clipboard

Vars of included Taskfiles in included Taskfiles

Open maxwassiljew opened this issue 3 years ago • 0 comments

  • Task version: Task versionv3.12.1
  • Operating System: Linux

I have encountered an inconsistency in vars of included taskfiles and need some assistance. The setup I have looks like this. There is a common-include taskfile and a package1 taskfile. The parent taskfile includes both taskfiles. The package1 also includes common-include. The problem arises with the variables that are passed. From parent to common-include everything works fine but from package1 to common-include the passed variable is simply ignored.

Example Taskfile showing the issue

❯ tree .
.
├── include
│   └── Taskfile.include.yaml
├── package1
│   └── Taskfile.package1.yaml
└── Taskfile.yaml

2 directories, 3 files

./Taskfile.yaml

version: '3'

includes:
  included:
    taskfile: ./include/Taskfile.include.yaml
    vars:
      VAR_1: provided-from-parent-var1
  package1:
    taskfile: ./package1/Taskfile.package1.yaml

tasks:
  default:
    cmds:
      - task: included:task1

./package1/Taskfile.package1.yaml

version: '3'

includes:
  included:
    taskfile: ../include/Taskfile.include.yaml
    vars:
      VAR_1: provided-from-package1-var1

tasks:
  default:
    cmds:
      - task: included:task1

./include/Taskfile.include.yaml

version: "3"

vars:
  VAR_1: '{{.VAR_1 | default "included-default-var1"}}'

tasks:
  task1:
    cmds:
      - echo "VAR_1 is {{.VAR_1}}"
❯ go-task
task: [included:task1] echo "VAR_1 is provided-from-parent-var1"
VAR_1 is provided-from-parent-var1

❯ go-task package1:default
task: [package1:included:task1] echo "VAR_1 is included-default-var1"
VAR_1 is included-default-var1

By executing go-task the default task from parent is executed and the VAR_1 has the provided value. By executing go-task package1:default the default task from package1 is executed and the VAR_1 does not have the provided value provided-from-package1-var1 but the default value from the common-include included-default-var1.

maxwassiljew avatar Jun 14 '22 09:06 maxwassiljew