Skip to content

Vars of included Taskfiles in included Taskfiles  #778

@maxwassiljew

Description

@maxwassiljew
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions