Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
QianChenglong opened this issue Apr 17, 2024 · 2 comments

Comments

@QianChenglong
Copy link

image image

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

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Apr 17, 2024
@MarioSchwalbe
Copy link
Contributor

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:.

@vmaerten
Copy link
Collaborator

Yes, you need to use default function

@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants