-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
Cannot override global variables in included Taskfiles since 3.36.0 #1588
Comments
Same issue here. Passing in a variable with the intention of overriding a variable that is defined in the top-level The workaround is to use the vars:
DOCKER_IMAGE: {{ .DOCKER_IMAGE | default "default_image" }} |
FWIW, using an anchor in the vars works: # taskfile A
version: 3
vars:
VAR: "bar"
tasks:
echo:
cmds:
- echo {{ .VAR }}
---
# taskfile B
version: 3
def: &var
VAR: "foo"
includes:
A:
taskfile: Taskfile.A.yaml
tasks:
echo:
cmds:
- task: A:echo
vars:
*var which outputs # ...
echo:
cmds:
- task: A:echo
vars:
<<: *var echos If you're like me and have a bunch of variables that you don't want to hardcode over and over, the anchors proved to be a sufficient workaround. |
This looks to be related to #1533. I was slightly worried about the potential for this to break Taskfiles at the time. I'll take a more detailed look at this soon. Edit: It was decided that this was a bugfix at the time and that the proper way was to use As an aside - @MarioSchwalbe, I see that in your repro example, you are including the same Taskfile twice with two different namespaces. Is this a common setup for you? The upcoming DAG changes (#1563) which will be included in the next release would actually restrict this functionality. It's not something that I thought would be useful or common at the time. Please let me know if you think otherwise. |
@jclasley I'm not able to reproduce your second example. Firstly, I have assumed that you have a file named Could you please double check that your example properly reproduces the behaviour you're seeing and update it if necessary. Thanks. |
@pd93 you're right, the second one works as expected. I thought that it was the inclusions that were messing up, but now I realize I was declaring global vars in each child taskfile. Thank you for double-checking! |
Yes. This is definitely important as I'm using some sort of utility Taskfile to build multiple projects (in subdirectories) from within a Taskfile in the top-level directory. Additionally, these run in different directories like so: includes:
subA:
taskfile: DockerBuild.yml
dir: subA
subB:
taskfile: DockerBuild.yml
dir: subB
vars:
DOCKER_IMAGE: imageOfB |
Hi @pd93 I have the exact same use case than @MarioSchwalbe. I've opened an issue to discuss / track it : |
We need 2 task files (see https://taskfile.dev/usage/#vars-of-included-taskfiles):
Taskfile.yml
:and
DockerBuild.yml
:Since version 3.36.0 I get:
In previous versions it was possible to override variables when including taskfiles changing the second case to:
Is this an intended change? And if yes, how would we implement something like that instead?
The text was updated successfully, but these errors were encountered: