Task

T

Task

Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.

Join

Is this the best way to create a list (that can be empty) for use with templates?

```yml VENV_TO_INSTALL_STR: sh: |- for pkg in "{{join "" "" .PYTHON_PACKAGES}}"; do echo '{{.VENV_ALL_PACKAGES}}' | grep -q "{"name": "$pkg"" || echo "$pkg"...
Solution:
You could use compact instead of initial. This would remove any empty items from your array. Alternatively, you can build a JSON string and call fromJson. There are probably other ways too. Regarding ref. By design, it only accepts a single ActionNode (i.e. One set of {{...}}) so if statements are not possible. ref is designed for you to be able to refer to other variables while maintaining their type, not for logic. It is actually a side-effect of the templating engine that functions are available for use in ref, but we felt this was acceptable/useful....

Is it possible to to specify a Go version in a Taskfile?

When building a Taskfile.yml, is it possible to specify the Go version used when building the application? This is all I have in my Taskfile.yml: ```yaml...

variable for current taskfile?

Is there a variable can be used in taskfile works like __dirname in js , which is the directory of current taskfile.yaml ? for example, when CWD= /home/user/src/project1/internal/, running task with /home/user/src/project1/taskfile.yaml, a variable for /home/user/src/project1/...

Does precondition support go templates?

It seems that preconditions don't support the templates, or if they do, I'm unable to figure it out.

What environment anad shell are task commands executed in?

I am trying to evaluate the result of a command which pipes through tee so that output of the command is logged to the STDOUT and saved in a file at the same time. The idea is to then invoke a script that logs the outcome of the command depending on the exit code in a file. ```yaml task:...
Solution:
found it! if you put everything you want in a script and invoke the script as follows: ```shell...

Continue on error

Is there a functionality that could make a task continue execution even there is an error ? Context: I am trying taskfile to do CI checks....

dotnev variable value calculation

Hello ! I canot find anything in the docs so I decided to ask here: Is there some sort of prioirity in the dotenv declaraion?...
Solution:
Hello ! It'll be true. Dotenv files are processed in the order they are defined. If an environment variable already exists, it won't be overridden....

yaml formatted data

Assuming a variable ARRAY like in https://taskfile.dev/blog/any-variables/#arrays , but YAML formatted. Is it possible, loop over a variable containing YAML formatted data (in this case a list) either inline or loaded from a .yaml file with templating functions? example data: ```...

Precondition with OR does not work

Hey all, I have a build pre condition that checks two things: production or version. If the build is production I want to validate the version in my pre condition and if the build is not production I want to continue successfully without validating the version. When I run the two expression together it fails even when I specify PRODUCTION = false. That is, if I pass PRODUCTION == false I want to skip validating the version and continue successfully and if PRODUCTION == true I want to validate the version with my regex and fail if it is not a valid format. Here is my pre condition:...

Using sh to generate a map?

I've been taking a poke at https://github.com/go-task/task/issues/1585 very briefly but it made me wonder if there would be interest in something that would support using the output of a sh: into a map. This would allow me to create complex tasks or scripts that generate valid JSON for consumption by task (something I already do regularly for GitHub Actions matrixes). For instance: ```yaml...

Required input does not prevent dependencies from running and dependencies do not share variables

Hey all, I am running into two problems with my build release task: 1. In my dependencies section I have duplications with the variables I want to pass to each dependency. Do we have a way to pass common variables to all dependencies instead of explicitly setting them for each dependency?...

How to use for loop with filenames containing spaces?

I'm encountering an error when trying to run a Taskfile and need some help. My task needs to process filenames that may contain spaces. ``` task: Failed to run task "sample-for-cmd": 6:1: "foo(" must be followed by )...

Blocking Task?

Is there a way to have a "blocking" task so that it waits for it to complete first? (see the first task infra/up below) ```yaml yaml-language-server: $schema=https://taskfile.dev/schema.json version: "3"...

Should the 'generates' folders be automatically excluded from 'sources' evaluaton?

If I have a project structure of: ``` project: - src - build...
Solution:
ok, thanks. It seem like if the build directory is deleted and then recreated then it's thinking that the content has changed except I think the checksums for each file would be the same. I guess there's something different that I'm not realising. I'll close this question off as it's something specific to the project I'm working on. Thanks

Static context issues

As I understand it, once a task command is executed, its environment context cannot be changed. This means I can't set a global variable from a task, which introduces difficulties when running tasks that install software, update $PATH, or modify other environment variables. I'm not sure what the workaround could be at this point. However, my main point is that it would be very helpful to have a shared environment between tasks....

Path to Taskfile from environment variable

It would be great to have the option to set the path to the Taskfile using an environment variable. This would be particularly useful in scenarios where the Taskfile is not located in the default path (e.g., Taskfile.yaml), allowing us to avoid specifying the path each time.

Running task fails in git hooks

We have a pre push git hook which will run the build task. When it is executed normally it works without any problem. But during pre push it throws the following error "task: Failed to parse stdin yaml: line 1: cannot unmarshal !!str into taskfile" ...

is there a way to give required variables check in the root level similar to the task level?

We have a use case where any task can be runnable only when common environment variables are available. Instead of setting them up in each task, is there an possibility to set it at root level?

how task kill process?

I have a process handle SIGHUP SIGINT SIGKILL SIGTERM and SIGQUIT but they are not trigger, how task kill process in watch mode? it looks like it use differnt strategy to stop process when exit watch mode and in watch mode?...

Looking for advice - Rendering template files

Hi, I'm wondering what would be the best approach to handle rendering a whole bunch of template files. Having 1 folder containing many templates. Loading an env file for example and substitute all placeholders in these files to a location on fs. I used to do something alike using jinja2 and ansible but I don't want to use ansible or python. I'd just like to know if there is a smart way to do that using taskfile. Maybe leveraging go's sprig templating or the basic variable substitution with {{.EXAMPLE}} syntax , I'm not sure how to achieve that for many files....
Next