Skip to content

Cannot override global variables in included Taskfiles since 3.36.0 #1588

@MarioSchwalbe

Description

@MarioSchwalbe
  • Task version: 3.36.0
  • Operating system: Linux (probably others)
  • Experiments enabled: none

We need 2 task files (see https://taskfile.dev/usage/#vars-of-included-taskfiles):

Taskfile.yml:

version: '3'

includes:
  subA:
    taskfile: DockerBuild.yml

  subB:
    taskfile: DockerBuild.yml
    vars:
      DOCKER_IMAGE: imageOfB

tasks:
  default:
    cmds:
      - task: subA:show   # Uses the default value.
      - task: subB:show   # Used to be `imageOfB`. Now is `default_image`.

and DockerBuild.yml:

version: '3'

vars:
  DOCKER_IMAGE: default_image

tasks:
  show:
    cmds:
      - echo "DOCKER_IMAGE = {{.DOCKER_IMAGE}}"

Since version 3.36.0 I get:

$ task
task: [subA:show] echo "DOCKER_IMAGE = default_image"
DOCKER_IMAGE = default_image
task: [subB:show] echo "DOCKER_IMAGE = default_image"
DOCKER_IMAGE = default_image

In previous versions it was possible to override variables when including taskfiles changing the second case to:

$ task
task: [subA:show] echo "DOCKER_IMAGE = default_image"
DOCKER_IMAGE = default_image
task: [subB:show] echo "DOCKER_IMAGE = imageOfB"
DOCKER_IMAGE = imageOfB

Is this an intended change? And if yes, how would we implement something like that instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions