Skip to content

Vars don't get properly propagated with two levels of included nesting #996

@gsantoro

Description

@gsantoro

Hello,
thanks for the amazing tool that Taskfile is. I have a bit of advanced use case, so bear with me.

I am facing an issue with the current setup:

  • I have three Taskfiles: A, B, C
  • A includes B and calls B:up
  • B includes C and calls C:up
  • C has a variable that I want to be overridable: C_VARIABLE: '{{.C_VARIABLE | default "localhost"}}'

this is the content of A.Taskfile.yml:

version: '3'

includes:
  B: 
    taskfile: ./B.TaskFile.yml

tasks:
  up:
    cmds:
      - task: B:up

this is the content of B.Taskfile.yml:

version: '3'

vars:
  B_VARIABLE: b

includes:
  C: 
    taskfile: ./C.TaskFile.yml
    vars:
      C_VARIABLE: "{{.B_VARIABLE}}"

tasks:
  up:
    cmds:
      - echo "B_VARIABLE {{.B_VARIABLE}}"
      - task: C:up

and this is the content of C.Taskfile.yml

version: '3'

vars:
  C_VARIABLE: '{{.C_VARIABLE | default "localhost"}}'

tasks:
  up:
    cmds:
      - echo "C_VARIABLE {{.C_VARIABLE}}"

If I run the following command it behaves as expected. Meaning that when B:up calls C:up, it overrides the variable C_VARIABLE with the content of B_variable=b

➜ t -t B.Taskfile.yml up
task: [up] echo "B_VARIABLE b"
B_VARIABLE b
task: [C:up] echo "C_VARIABLE b"
C_VARIABLE b

if instead I run the same up task from A

➜ t -t A.Taskfile.yml up
task: [B:up] echo "B_VARIABLE b"
B_VARIABLE b
task: [B:C:up] echo "C_VARIABLE localhost"
C_VARIABLE localhost

the C_VARIABLE is not overridden but it uses the default value instead.

This is not what I was expecting

➜ t -t A.Taskfile.yml up
task: [B:up] echo "B_VARIABLE b"
B_VARIABLE b
task: [B:C:up] echo "C_VARIABLE b"
C_VARIABLE b

Am I doing something wrong? Do I have wrong expectations or is this a bug?

  • Task version: v3.20.0
  • Operating System: MacOS arm64 architecture

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