Dynamic Triggers in Harness for git events

This article gives an overview of the dynamic triggers available in Harness and focuses on the working of these triggers according to the events marked in GitHub webhooks. This helps developers come up with custom triggers according to their use case.

Published on

Trigger, a key term used, to represent a step to automate deployment or initiate a pipeline build. As seen in the table below taken from CD.Foundation’s mapping of common terminologies, trigger is used by almost all CI/CD tools available.

Likewise in harness are used in deployments to automate the CI/CD pipeline based on various git events namely PUSH, CREATE & ALL, which thereby can be used to trigger a pipeline automatically based on these events.

Why do we need it?

Triggers enable event driven CI/CD and support the practice of every commit building and/or deploying to a target environment. 

How Triggers are based on various git events?

Pipelines could be triggered  in response to Git events automatically. For example, when a pull request or push event occurs on a Git repo, a CI or CD Pipeline can execute.

The triggers work on a certain predefined conditions, which help to form the overall set of criteria to trigger a Pipeline based on changes in a given source. In harness we have categorised the conditions to be based on 3 git events:

  1. Pull Request
  2. Issue Comment
  3. Push

Which are further attributed by 

For example:

  • Execute Pipeline if the source/target branch name matches a pattern.
  • Execute Pipeline if the event is sent for file changes from specific directories in the Git repo. This is very useful when working with a monorepo (mono repository). It ensures that only specific Pipelines are triggered in response to a change.

Making it work with GitHub web-hooks:

For configuring the GitHub web-hooks harness uses events API to choose which events will send the payloads. 

Here’s an example of payloads conditions described in Harness for triggers:

payloadConditions: - key: <+trigger.payload.ref> operator: Contains value: tags - key: <+trigger.payload.base_ref> operator: Contains value: main

The following resources could be used to get more information on how trigger Pipelines in response to Git events that match specific payload conditions you set up in the Harness Trigger, also to customize the trigger for Github payload conditions:

  1. Trigger pipelines using Git events
  2. Trigger Pipeline using Git events payload conditions

Need further help? 

Feel free to ask questions at community.harness.io or  join community slack to chat with our engineers in product-specific channels like:

The Modern Software Delivery Platform®

Loved by Developers, Trusted by Businesses
Get Started

Need more info? Contact Sales