v3.3 and after
LifecycleHook triggers an action based on a conditional expression. It is configured either at the workflow-level or template-level, for instance as a function of the
steps.status, respectively. A
LifecycleHook executes during execution time and executes once.
In other words, a
LifecycleHook functions like an exit handler with a conditional expression.
LifecycleHook: Executes the workflow when a configured expression is met.
Template-level Lifecycle-Hook: Executes the template when a configured expression is met.
outputsare not usable since
LifecycleHookexecutes during execution time and
outputsare not produced until the step is completed.
Notification use case¶
LifecycleHook can be used to configure a notification depending on a workflow status change or template status change, like the example below:
apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: lifecycle-hook- spec: entrypoint: main hooks: exit: template: http running: expression: workflow.status == "Running" template: http templates: - name: main steps: - - name: step1 template: heads - name: heads container: image: alpine:3.6 command: [sh, -c] args: ["echo \"it was heads\""] - name: http http: url: http://dummy.restapiexample.com/api/v1/employees