1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

go/task Taskfile TIPS

Last updated at Posted at 2019-01-18

dynamic variable concatenation

# Taskfile.yml

version: '2'

vars:
  staticTopLevelVar: static
  dynamicTopLevelVar: '{{ .pfx }}:{{ .staticTopLevelVar }}'

.dynamic_vars: &dynamic_vars
  dynamicVar: '{{ .pfx }}:{{ .staticTopLevelVar }}'
  dynamicVarReferencesOtherDynamicVar: '{{ .dynamicVar }}:dynamicVarReferencesOtherDynamicVar'

tasks:
  echo:
    cmds:
      - echo '{{ .staticTopLevelVar }}'
      - echo '{{ .dynamicTopLevelVar }}'
      - echo '{{ .dynamicVar }}'
      - echo '{{ .dynamicVarReferencesOtherDynamicVar }}'
    vars:
      <<: *dynamic_vars
    silent: true

as you can see, you cannot concatenate top level vars.
you have to use task vars to concatenate predefined vars with argument vars.

task echo pfx=my-prefix
static
<no value>:static
my-prefix:static
my-prefix:static:dynamicVarReferencesOtherDynamicVar
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?