No items found.
October 4, 2022

Dynamic Triggers in Harness for git events

Table of Contents

Key takeaway

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:

You might also like
No items found.

Similar Blogs

No items found.
Continuous Delivery & GitOps
Continuous Integration