Skip to content

Catch

A catch statement is also a sequence of operations or collectors.

Operations and collectors contained in a catch statement will be executed only if the step failed when executing the operations in the step's try statement.

Tip

All operations and collectors of a catch statement will be executed regardless of the success or failure of each of them.

Operations

A catch statement supports only the following operations:

Collectors

A catch statement supports all collectors:

Example

Example

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
  name: catch
spec:
  steps:
  - try: []
    catch:
      - description: "Description of the catch operation"
        command:
          entrypoint: "/bin/bash"
          args: ["-c", "echo 'catch block'"]
        events: {}
        sleep:
          duration: 1s
        podLogs: {}
    finally: []