Skip to content

Support for inline / anonymous task blocks within other tasks #2470

@adrianlungu

Description

@adrianlungu

Description

It would be really nice if Taskfile supported inline (anonymous) tasks inside another task’s cmds, i.e.

version: "3"

tasks:
  release:
    desc: Full release pipeline example
    vars:
      VERSION: "v1.2.3"
    cmds:
      - task:
          name: build
          vars:
            TARGET: "linux/amd64"
          cmds:
            - echo "Building for {{.TARGET}}..."
            - go build -o bin/app_{{.VERSION}} ./cmd/app

      - task:
          name: test
          condition: '"{{.CI}}" == "true"'
          cmds:
            - echo "Testing in CI mode..."
            - go test ./...

      - task:
          cmds:
            - echo "Tagging release {{.VERSION}}"
            - git tag {{.VERSION}}
            - git push origin {{.VERSION}}

There are a lot of cases where I want to group a few commands together — maybe with their own local variables and conditions — but they’re too specific to justify a separate top‑level task.

Each inline task: block would behave like a child task:

  • Has access to parent vars / env
  • Can override or define local ones
  • Can have its own condition and cmds
  • Runs sequentially as declared
  • Effectively, it’d let you structure logic locally without cluttering the global namespace.

This would make bigger automation flows cleaner and easier to maintain, without creating a dozen single‑use top‑level tasks just to get proper isolation or conditions.

TL;DR
Support task: blocks inline under a parent’s cmds, optionally with name, vars, condition, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions