Skip to main content

Event Listener Step

The Event Listener Step introduces an event-driven mechanism to Harness pipelines, eliminating the need for polling and improving performance. Instead of continuously checking for status updates, this step reacts to webhook events in real time to determine whether a pipeline should resume or fail based on predefined conditions.

note

This feature is behind the feature flag: CDS_EVENT_LISTENER_STEP

Key Features

  • Webhook Event Handling
    Processes incoming webhook events to either resume or fail pipeline execution based on the event payload.

  • Success/Failure Criteria

    • Harness uses JEXL expressions to define success and failure conditions.
    • Success Criteria (required) is always evaluated first and takes precedence. If success criteria is met, the pipeline resumes.
    • Failure Criteria (optional) is evaluated only if the success criteria is not met. If the failure criteria is met, the step fails and the corresponding failure strategy (step or stage-level) is applied.
    • If no failure criteria is provided, the step continues to wait for an event that meets the success criteria until the timeout is reached.
  • Event-Driven
    Eliminates the overhead of polling by listening for relevant events as they occur.

Configuring an Webhook

Refer Generic Webhook Documentation to know more about how to create a webhook.

Configuring an Event Listener Step

Follow these steps to set up a Google Cloud Run Service in Harness:

Here is an interactive guide to setup your Event Listener Step pipeline.

Use Cases

Use Cases

Suppose the webhook payload received is:

{
"event": "ping",
"data": {
"success": true
},
"webhook": "EventListenerTest",
"action": "SUCCESS"
}
  1. Success Criteria: <+event.payload.action> == "SUCCESS"

Since action is "SUCCESS", the success criteria is met and the step succeeds.

  1. Success Criteria: <+event.payload.action> == "SUCCESS" Failure Criteria: <+event.payload.webhook> == "EventListenerTest"

Both conditions are met (action is "SUCCESS" and webhook is "EventListenerTest"). Because success criteria is evaluated first, the step succeeds.

  1. Success Criteria: <+event.payload.action> == "Null" Failure Criteria: <+event.payload.webhook> == "EventListenerTest"

The success criteria fails (action is not "Null"). The failure criteria passes (webhook is "EventListenerTest"). The step fails.

  1. Neither Criteria Met

If neither the success nor failure criteria is met, the step waits for additional events that might match until the time-out is reached.

Sample Pipeline YAML

Sample yaml

Here is the sample pipeline yaml for the EventListener step

pipeline:
name: Event-Listener
identifier: EventListener
projectIdentifier: projectIdentifier
orgIdentifier: default
tags: {}
stages:
- stage:
name: stage1
identifier: stage1
description: ""
type: Custom
spec:
execution:
steps:
- step:
type: EventListener
name: EventListener_1
identifier: EventListener_1
spec:
webhookIdentifier: Event_listener
successCriteria: <+event.payload.action>=="SUCCESS"
failureCriteria: <+event.payload.action>=="FAILURE"
timeout: 10m
tags: {}