Skip to content

Task envars are not available in templater. #2807

@trulede

Description

@trulede

Description

Task envars are not made available to the templater. This was probably the original intention, however with dotenv as a method of exchanging values between tasks it would be useful to have those envars also available in the templater.

global.env

gfoo=gfoo

task.env

tfoo=tfoo

Taskfile.yml

version: '3'

dotenv:
  - global.env

tasks:
  default:
    desc: Print a greeting message
    dotenv:
      - task.env
    env:
      tbar: tbar
    cmds:
      - echo "env gfoo = $gfoo"
      - echo "env tfoo = $tfoo"
      - echo "env tbar = $tbar"
      - echo "var gfoo = {{.gfoo}}"
      - echo "var tfoo = {{.tfoo}}"
      - echo "var tbar = {{.tbar}}"
    silent: true

Output:

$ task -d ISSUES/997/
env gfoo = gfoo
env tfoo = tfoo
env tbar = tbar
var gfoo = gfoo
var tfoo = 
var tbar = 

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: envChanges related to environment variables.area: templatingChanges related to the templating engine.
    No fields configured for feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions