Skip to content

Env access for sh vars #1742

@titpetric

Description

@titpetric

I declared global env in a taskfile like so:

---
version: "3"

env:
  DB_DRIVER: mysql
  DB_DSN: "etl:etl@tcp(localhost:3306)/etl"

tasks:
  default:
    desc: "Fill repos with details"
    vars:
      repos:
        sh: env | grep DB_ || true
    cmds:
      - env | grep DB || true
      - for: { var: repos, as: repo, split: "\n" }
        silent: true
        cmd: echo "X{{.repo}}"

The expected output of this would be:

DB_DRIVER=mysql
DB_DSN=etl:etl@tcp(localhost:3306)/etl
XDB_DRIVER=mysql
XDB_DSN=etl:etl@tcp(localhost:3306)/etl

Actual output of this is:

DB_DRIVER=mysql
DB_DSN=etl:etl@tcp(localhost:3306)/etl
X

Seems the vars sh are not picking up the taskfile env which would be my expectation...

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