-
-
Notifications
You must be signed in to change notification settings - Fork 617
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
Task variable level overrides no longer work in recent releases #1665
Comments
This is relating to import/included tasks. Where are the default values defined? Variables specified at the inclusion have a fairly low priority: My own experiment show that this behavior is not working as expected. Global variables take precedence over variables defined at inclusion. Taskfile
a/Taskfile
$ ~/go/bin/task one I don't think this is covered by the tests (global vars or environment vars). Seems like a bug. But is it the problem you observe? |
Yes @trulede, you are correct. These are top-level variables that previously I was able to override at inclusion time. Now the global variables are taking precedence over the variables set at inclusion time. This is definitely a bug/regression that has been introduced in the last several versions. Task is not honoring the precedence contract described in https://taskfile.dev/usage/#variables |
I'm using this tool for the first time now, so I cannot comment on how the behavior was before. But I think I'm experiencing the same behavior. I have 2 taskfiles (let's call them
which is consistent with the behavior I'm getting (unfortunately 😅). I'm trying to use In any case, UX wise, I think it would make more sense for variables overriden at inclusion to have higher priority than the ones defined as global variables. |
@blakewatters I believe there is a work-around via the
This worked for me: # Taskfile.yml
version: '3'
includes:
child-with-var:
taskfile: ./Taskfile.child.yml
vars:
VAR: value-from-parent
child-without-var:
taskfile: ./Taskfile.child.yml
tasks:
default:
cmds:
- task: child-with-var
- task: child-without-var # Taskfile.child.yaml
version: '3'
vars:
VAR: '{{ .VAR | default "value-from-child" }}' # This can get overridden.
tasks:
default: echo {{.VAR}} Output:
Would this resolve your use-case? |
I do see this tip here:
(source) This does sound like intended behaviour and not a bug. What is good about this approach is that it allows the included file to control which vars can be overridden from the outside and which ones cannot. |
Hey @blakewatters, @pbitty is right. Default is the way to go. You can find a previous issue here, where we discussed the behavior. |
Since upgrading task to latest v3.37.x releases I am seeing variable overrides for included tasks functioning as no-ops. For example, given this task include:
The
OSIRIS_ENV
andGOOGLE_CLOUD_PROJECT
remain at their default values rather than the explicitly overridden values.The text was updated successfully, but these errors were encountered: