-
-
Notifications
You must be signed in to change notification settings - Fork 616
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
Global variables and included taskfile #696
Comments
For clarification, your expectation is that root vars take precedence over vars of the same name coming from an include? |
Try upgrading to 3.12 and check out this part of the docs: https://taskfile.dev/#/usage?id=vars-of-included-taskfiles See if that helps. |
Yes, I did not expect that variable
Yes, we are aware of this new feature in 3.12 but it seems as a workaround for the real issue, hence we wanted to first check if the above is wanted behavior or do you consider it as a bug as we do? |
This is not a bug. It was a conscious design decision. The reason why is that the goal is to allow you to essentially use included task files like composable pieces. Being able to create multiple namespaces and such using the same file (via an include). The style guide and other documentation likely should be updated to show some examples and specific scenarios that you may encounter, and how best to structure your Taskfile's. |
But I don't want to leave you hanging with this answer. The examples in your original post, though very good minimal reproducible example files, don't demonstrate the use case you have. Would you mind providing more detailed information on your use case, and I can help guide you to a working solution/pattern? |
@ghostsquad thanks for your help! I am in the same team as @aliculPix4D and we are using a fork I did to fix a problem with signal propagation to subprocesses (see #479). At this point, I think it makes more sense for us to upgrade the fork to 3.12 (given the changes in var handling you mention) and then continue this discussion. |
@aliculPix4D @marco-m-pix4d How did you get on with 3.12? Are you still having issues, or can this be closed? |
hello @pd93, we switched to using Task upstream (as opposed to our fork), because Task handles signal propagation better since 3.13. Regarding this specific issue, @aliculPix4D could you please confirm wether we are still seeing this behavior, and if yes, would it be possible to "demostrate the use case we have" as requested in #696 (comment) ? Thanks :-) |
First sorry for the late reply. I had a look at the issue again. Here is my summary:
Looking at: https://taskfile.dev/usage/#vars-of-included-taskfiles and trying to modifing my examples above to implement suggestions from documentation (using Task v3.17.0): root Taskfile content:
imported Taskfile content
which in my opinion even further shows that this ticket is needed and that the behavior described in the issue should be a bug and not a wanted behavior. Why?
Our use case is not much different than these simple examples with echo. We use Task to drive our |
We're facing a similar issue. The idea is to have a reusable Taskfile with a configurable version of a command line tool. In this example, a docker image tag is to be configured.
Unfortunately, it seems like Taskfile evaluates global variables in the included file independently from any variables provided by the including file. # Taskfile.yaml
version: '3'
includes:
docker:
taskfile: Taskfile_docker.yaml
vars:
TAG: bookworm # Taskfile_docker.yaml
version: '3'
vars:
TAG: '{{.TAG|default "latest"}}'
CMD: 'docker run debian:{{.TAG}}'
tasks:
test:
cmds:
- '{{.CMD}}} echo "{{.TAG}}"'
Notice A workaround for this issue is to use environment variables in the root Taskfile to override variables in included Taskfiles. But this doesn't allow to override of a variable with different values in different included Taskfiles. # Taskfile.yaml
version: '3'
env:
TAG: bookworm
includes:
docker: Taskfile_docker.yaml
Notice |
As v3.36.0 with the recent changes of how to handle vars passed to included Taskfile (#1533). |
Very similar issue: #618
Hi, first thank you for the great tool. I would like to report what my team and I consider a bug (unexpected behavior) and to check your opinion on the topic.
Consider the following setup:
import
and included from the root TaskfileRunning the following commands:
While our expectation were more in line with the following:
where the root task would print the value set in root Taskfile.
Thanks for looking at this issue.
The text was updated successfully, but these errors were encountered: