Skip to content

Instantly share code, notes, and snippets.

@isubasinghe
Created December 22, 2025 08:20
Show Gist options
  • Select an option

  • Save isubasinghe/27dc05e41ccb6b33e28e39d2b92dc108 to your computer and use it in GitHub Desktop.

Select an option

Save isubasinghe/27dc05e41ccb6b33e28e39d2b92dc108 to your computer and use it in GitHub Desktop.
notify on dag task level on failure
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: dag-diamond-hooks-
spec:
entrypoint: main
templates:
- name: main
dag:
tasks:
- name: A
template: worker
hooks:
failure:
expression: "true" # Required by some 'main' branch builds
template: notifier
arguments:
parameters: [{name: task-id, value: "Node A"}]
- name: B
depends: "A"
template: worker
hooks:
failure:
expression: "true"
template: notifier
arguments:
parameters: [{name: task-id, value: "Node B"}]
- name: C
depends: "A"
template: worker
hooks:
failure:
expression: "true"
template: notifier
arguments:
parameters: [{name: task-id, value: "Node C"}]
- name: D
depends: "B && C"
template: worker
hooks:
failure:
expression: "true"
template: notifier
arguments:
parameters: [{name: task-id, value: "Node D"}]
- name: worker
container:
image: alpine:latest
command: [sh, -c]
args: ["if [ $(($RANDOM % 2)) -eq 0 ]; then echo 'Success'; exit 0; else echo 'Failing'; exit 1; fi"]
- name: notifier
inputs:
parameters:
- name: task-id
container:
image: alpine:latest
command: [echo]
args: ["ALERT: Task '{{inputs.parameters.task-id}}' failed."]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment