Skip to content

includes doesn't interpolate paths #942

Closed
@fatmcgav-depop

Description

@fatmcgav-depop

Hi there

Firstly, I'm not sure if this is strictly a bug or a feature request.
However the docs mention that it's possible to interpolate using the {{OS}} value, so I'd expect to be able to use other vars...

Anyhow, I've got a setup that leverages the includes functionality to dynamically include another Taskfile.
The challenge is that the path to that downstream taskfile varies based on user input.

E.g.

---
version: "3"

vars:
  MODULE_NAME:
    sh: jq -r .module_name cookiecutter.json

includes:
  # Support running tasks defined in the generated template module
  generated:
    taskfile: './cookiecutter-temp/{{ .MODULE_NAME }}'
    dir: './cookiecutter-temp/{{ .MODULE_NAME }}'
    optional: true

However the tasks don't get loaded by task.

If I replace {{.MODULE_NAME}} in the above with a "qualified" location then the includes work as expected:

task -l |grep generated
* generated:deps:               Install required dependencies
* generated:go-mod:             Downloads and tidy Go modules
* generated:pre-commit-install: Add `pre-commit` hook
* generated:python-deps:        Install required python dependencies in a virtualenv
* generated:terraform:          Set up and validate the Terraform Module
* generated:terraform-checkov:  Analyise the Terraform Configuration
* generated:terraform-docs:     Update the README.md file
* generated:terraform-e2e:      Run the Terraform integration test suite
* generated:terraform-fmt:      Format the Terraform module code
* generated:terraform-init:     Initialize the Terraform environment
* generated:terraform-validate: Validate the Terraform module code
* generated:test:               Run tests.
* generated:test-go:            Run tests for all Go code.
  • Task version: 3.18.0
  • Operating System: MacOS 12

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