Skip to content

Merging not working properly with yaml reference block #2154

@rfan-debug

Description

@rfan-debug

Description

It seems the yaml reference block merging hasn't been resolved yet.

The following taskfile.yml code cannot inherit the variable MAGIC as long as there is another vars field defined in rhel6

version: "3"
tasks:
  task_rhel7: &anchor
    cmds:
      - echo {{.VERSION}}
      - echo {{.MAGIC}}
    vars:
      VERSION: rhel7
      MAGIC: magic
  task_rhel6:
    <<: *anchor
    vars:
      VERSION: rhel6

Output:

task task_rhel6
task: [task_rhel6] echo rhel6
rhel6
task: [task_rhel6] echo

I'd expect the task task_rhel6 echoes the MAGIC variable properly.

Related issues:

  1. Merging not working with go-task 2.0 #112
  2. Merge with overrides doesn't work in strict mode go-yaml/yaml#410. It seems that the go/yaml merge issues won't be fixed since the repository has been archived.

Version

3.42.0

Operating system

MacOS 15

Experiments Enabled

No response

Example Taskfile

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions