I have three tasks created with TASKFILE, main-task
and its two preconditions(or deps) e.g A
and B
. I need the main-task
to run task A
, if task A
works fine and did the job then ignore the second task B
, otherwise fallback to task B
and execute it (that's why I added ignore_error: true
). How to put this logic inside main-task
using taskfile syntax? thanks
Example:
---
version: 3
tasks:
A:
cmds:
- cmd: exit 1
ignore_error: true
B:
cmds:
- exit 1
main-task:
deps: # Run A only, But if it fails then Run B
cmds:
- task: # or here: Run A only, But if it fails then Run B
Unfortunately, there isn't a way to run a task only if another one failed. You can run it only if succeeded by calling it after the previous one, or always by using defer
.