How to define global variables for all taskfiles

Hello. Could you please help me. I can't find a way how to define global variables for all Taskfiles. I have a lot of Taskfiles and want to define some "user-defined" variables that will be applied for all Taskfiles, but can't find a way how to do it. I tried to create some Taskfile
version: '3'

vars:
VAR1: value1
VAR2: value2
VAR3: value3
version: '3'

vars:
VAR1: value1
VAR2: value2
VAR3: value3
and include it to all other Taskfiles
includes:
config:
taskfile: ./cfg/config.yml
flatten: true
includes:
config:
taskfile: ./cfg/config.yml
flatten: true
but it looks like variables doesn't propagated with this way. Do we have some other way how to define set of variables in separate file and include them to Taskfile? Or maybe some way how to define global variables? Thank you for your support!
1 Reply
millerovtr
millerovtrOP4d ago
Let me give you more context: I have a structure like
project-root/

├── Taskfile.yml
├── stream1/
│ ├── component1/
│ │ └── Taskfile.yml
│ ├── component2/
│ │ └── Taskfile.yml
├── stream2/
│ ├── component1/
│ │ └── Taskfile.yml
project-root/

├── Taskfile.yml
├── stream1/
│ ├── component1/
│ │ └── Taskfile.yml
│ ├── component2/
│ │ └── Taskfile.yml
├── stream2/
│ ├── component1/
│ │ └── Taskfile.yml
And for each Taskfile.yml I want to have command that I want to call in any directory in cd project-root I want to have: - task command - task stream1:command - task stream1:component1:command cd project-root/stream1: - task command - task component1:command cd project-root/stream1/task1: - task command And task with includes works great for this structure. But I want to define some variables that will be available in every Taskfile. It's doesn't matter from what directory I calls task, it should use variables that I defined somewhere in one place. There may be about 10 of these variables and I would not have to copy them to each Taskfile. May be you can suggest some other options how to resolve my issue 🙂

Did you find this page helpful?