task icon indicating copy to clipboard operation
task copied to clipboard

New feature: action on error

Open edillmann opened this issue 6 years ago • 6 comments

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

edillmann avatar Oct 22 '18 08:10 edillmann

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 ?

marco-m avatar Jun 03 '20 16:06 marco-m

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.

andreynering avatar Jun 11 '20 20:06 andreynering

Hello @andreynering, I am happy that v3.3.0 added #327, thanks! Now, I would like to bring back to your attention this one :-)

marco-m avatar Mar 22 '21 15:03 marco-m

I like how ConcourseCI does this. It feels very natural and quite powerful:

https://concourse-ci.org/modifier-and-hook-steps.html

ghostsquad avatar Dec 09 '21 03:12 ghostsquad

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).

andreynering avatar Feb 11 '23 22:02 andreynering

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"

tennox avatar Nov 26 '23 13:11 tennox