task
task copied to clipboard
Temporary folder (.task) is not exposed as a special variable
Most people would probably hardcode the .task in their config files but the few that use TASK_TEMP_DIR variable to customize it will have a problem as there is no special variable for the current value of the task temp directory.
Another thing that I find weird is that I did not see taskfile creating this folder and I was expecting that it would be automatically created when absent.
Hi @ssbarnea, there is no special variable for TASK_TEMP_DIR. However, the value should still be accessible as the env is passed through to any tasks:
version: '3'
tasks:
default:
cmds:
- echo $TASK_TEMP_DIR
- echo {{.TASK_TEMP_DIR}}
> TASK_TEMP_DIR=".tasktest" task
task: [default] echo $TASK_TEMP_DIR
.tasktest
task: [default] echo .tasktest
.tasktest
Tested on v3.33.1
Another thing that I find weird is that I did not see taskfile creating this folder and I was expecting that it would be automatically created when absent.
The folder is also created for me when I run this task.
These behaviors are only true if TASK_TEMP_DIR is actually set. If not, .task is not automatically created, and the env var is empty when evaluated.
I think the issue was created because these wanted behaviors aren't performed with an unset TASK_TEMP_DIR when they should.
Hi,
As @pd93 said, the only way to override the temporary folder is with the TASK_TEMP_DIR environment variable. As all env variables are exposed in the templating system, you are able to do something like this :
version: '3'
vars:
TASK_TEMP_DIR: '{{.TASK_TEMP_DIR | default ".task" }}'
tasks:
default:
cmds:
- echo {{.TASK_TEMP_DIR}}
The folder is created no matter if TASK_TEMP_DIR is set or not, but it's only created if we need it (e.g: we need to store fingerprint and/or remote cache)