task
task copied to clipboard
New feature: action on error
Hi,
I'm using go-task to automate simple data integration workflows, and i'am dreaming on a way to execute a task when a task return's an error,
Eric
Hello @andreynering, would you consider this feature for v3 ? I find it quite useful. Do you have any suggested workaround to obtain the same effect with the current task
?
Conceptually, I think we are talking about something like on-error
:
tasks:
foo:
cmds:
- cmd1
- ...
- cmdN
on-error:
- cmdA
- ...
- cmdK
Am I on the same page @edillmann ?
Hi @marco-m,
Not for v3.0 because this version is late enough (we've been working on it for more than a year).
But for v3.1 or later, yes.
Hello @andreynering, I am happy that v3.3.0 added #327, thanks! Now, I would like to bring back to your attention this one :-)
I like how ConcourseCI does this. It feels very natural and quite powerful:
https://concourse-ci.org/modifier-and-hook-steps.html
IDEA: We could easily add this by adding a new special variable on defer:
commands.
We need to think about the best UX, though. It could be IS_ERROR
(bool), EXIT_CODE
(int) or maybe just ERROR
(string).
I'd say EXIT_CODE
is most ~~intuitive~~ well-known :sweat_smile:
build:
cmds:
- foo.sh
- defer: if [[ {{EXIT_CODE}} -ne 0 ]]; notify-send "Build error"; fi
It's a bit of a mouthful though, and I'd much prefer something like:
build:
cmds:
- foo.sh
on_error:
- notify-send "Build error"