Skip to content

Variables getting cached in different iteration #2412

@ShivKJ

Description

@ShivKJ

Description

  • i am running "for-loop" in Taskfile
  • in each iteration, i am running another task which is calculating epoch in its vars
  • but in each iteration i am getting same value of epoch even though sleep is added to produce new epoch value.

Question: Does Task "cache" the variable values?

Expectation: My expectation is that if another task (say B) is called in a task, then every time task B is invoked, it should be calculating variables in vars. This is specially useful when looping is involved.

Version

3.44.1

Operating system

MacOS

Experiments Enabled

No response

Example Taskfile

version: 3

silent: true

tasks:
  test:
    vars:
      X: [A, B, C]

    cmds:
      - for:
          var: X
          as: x

        task: test-one

        vars:
          x: '{{.x}}'

  test-one:
    internal: true

    vars:
      epoch_time_now:
        sh: date +%s%N

    cmds:
      - echo "epoch_time_now={{.epoch_time_now}} with x={{.x}}" # this value does not change across different iteration
      - sleep 1 # adding sleep to ensure that next iteration sees different epoch value but still getting the same value of epoch_time_now

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions