-
-
Notifications
You must be signed in to change notification settings - Fork 754
Open
Labels
state: needs triageWaiting to be triaged by a maintainer.Waiting to be triaged by a maintainer.
Description
Description
With the following taskfile:
version: 3
vars:
TIME: '{{ now }}'
tasks:
main:
cmds:
- task: sub1
- task: sub2
sub1:
cmds:
- echo {{ .TIME }}
sub2:
cmds:
- echo {{ .TIME }}I'd expect the value to be the same for both tasks, but instead I get the following output:
task: [sub1] echo 2025-01-15 11:26:00.963791733 +0100 CET m=+0.035128847
2025-01-15 11:26:00.963791733 +0100 CET m=+0.035128847
task: [sub2] echo 2025-01-15 11:26:00.967687754 +0100 CET m=+0.039024858
2025-01-15 11:26:00.967687754 +0100 CET m=+0.039024858
This make it impossible to use that variable as e.g. a version tag for an artifact.
This behavior might be as intended, but there's no mention of that in the docs, and I see no way to make it be evaluated only once :(
Cheers!
Version
Task version: v3.40.0 (h1:1gKx+2UDz06Jtm0MBiN+EqVN87wWEyspuEze4LRGusk=)
Operating system
Linux
Experiments Enabled
No response
Example Taskfile
version: 3
vars:
TIME: '{{ now }}'
tasks:
main:
cmds:
- task: sub1
- task: sub2
sub1:
cmds:
- echo {{ .TIME }}
sub2:
cmds:
- echo {{ .TIME }}Metadata
Metadata
Assignees
Labels
state: needs triageWaiting to be triaged by a maintainer.Waiting to be triaged by a maintainer.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
trulede commentedon Jan 26, 2025
@Chewie The templating is exhibiting correct behaviour. You may use a "dynamic" variable and get the effect you desire.