task icon indicating copy to clipboard operation
task copied to clipboard

When calling a subtask, the passed variable cannot directly overwrite the value in the subtask, which is inconsistent with the document description.

Open QianChenglong opened this issue 1 year ago • 1 comments

image image

If use the template default method, cannot use shell commands to obtain the default value.

QianChenglong avatar Apr 17 '24 02:04 QianChenglong

Hi, this is because point 1 (variables declared in the task definition) has precedence. You can use the default function in something like this:

build:
  vars:
    PARAM: '{{ .PARAM | default "foo" }}'
    GOARCH_DEFAULT: { sh: go env GOARCH }
    GOARCH: '{{ .GOARCH | default .GOARCH_DEFAULT }}'
  cmds:
    - echo {{.GOARCH}} {{.PARAM}}

In case of GOARCH, you would need a helper variable, because this cannot be combined with sh:.

MarioSchwalbe avatar Apr 19 '24 11:04 MarioSchwalbe

Yes, you need to use default function

vmaerten avatar May 20 '24 19:05 vmaerten