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.
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:
- Pull Request
- Issue Comment
Which are further attributed by
- 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:
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:
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:
- #continuous-delivery Get support regarding the CD Module of Harness.
- #continuous-integration Get support regarding the CI Module of Harness.