Open ghostsquad opened 2 years ago
some more information on this:
version: '3'
tasks:
# works
foo:
cmds:
- echo '{{`${{blahblah}}`}}'
# works
foo2:
vars:
MYFOO: '{{`${{blahblah}}`}}'
cmds:
- echo '{{.MYFOO}}'
# fails
foo3:
cmds:
- task: foo2
vars:
MYFOO: '{{`${{blahblah}}`}}'
# successfully prints an empty string when called alone
foo4:
vars:
MYFOO: '{{.MYFOO}}'
cmds:
- echo '{{.MYFOO}}'
# fails
foo5:
cmds:
- task: foo4
vars:
MYFOO: '{{`${{blahblah}}`}}'
Looking at the source code, a task's variables are evaluated every time that task is run. So if you're passing a value through a chain of tasks it will be processed at each one. Perhaps there should be an option on variables to bypass the template engine.
Definitely think that's a bug.
Yes, a bypass option would work, but escaping also would work. Bypass in this case wouldn't work well, because it prevents any sort of default behavior.
As related to #179
Example Taskfile showing the issue
The more upvoted answer in stackoverflow indicates that this should work:
As should the following which is syntax needed for templating github actions workflow yaml file.
Gomplate (A CLI tool for go template) handles this just fine:
**Note that the trailing
%
is the shell's way of telling you there's no trailing newline character at the end of this output.Also reproducible on go playground: https://go.dev/play/p/JkgDIrUs3RQ
It's almost as if the
task
is double evaluating things?