Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: action on error #141

Open
edillmann opened this issue Oct 22, 2018 · 6 comments
Open

New feature: action on error #141

edillmann opened this issue Oct 22, 2018 · 6 comments

Comments

@edillmann
Copy link

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

@andreynering andreynering added the type: feature A new feature or functionality. label Oct 25, 2018
@marco-m
Copy link
Contributor

marco-m commented Jun 3, 2020

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 ?

@andreynering
Copy link
Member

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.

@marco-m
Copy link
Contributor

marco-m commented Mar 22, 2021

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

@ghostsquad
Copy link
Contributor

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

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

@andreynering
Copy link
Member

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

@tennox
Copy link

tennox commented Nov 26, 2023

I'd say EXIT_CODE is most intuitive well-known 😅

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"

@pd93 pd93 removed the type: feature A new feature or functionality. label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants