Tekton: Concepts of Triggers (Part 3)
This article is part of Series World of Tekton and discusses the concepts of Tekton Triggers.
This is Part 3 of the series, you can find the introduction here :)
Now, we have an idea how we can build a Pipeline but we don’t want to create a PipelineRun
manually right?
We want to automate the triggering of Pipeline on some events, for example. when we create a pull request on a git repository, then the Pipeline should be triggered and our CI must be executed.
This is where Tekton Triggers comes into picture :)
Tekton Triggers is a Tekton component that allows you to detect and extract information from events from a variety of sources and deterministically instantiate and execute TaskRuns
and PipelineRuns
based on that information.
Concepts :
There are multiple components in Triggers:
> TriggerTemplate <
TriggerTemplate specifies a blueprint for the resource, such as a TaskRun
or PipelineRun
, that you want to instantiate and/or execute when your detects an event.
In other words, TriggerTemplate holds the PipelineRun/TaskRun which we want to be created when an event occurs. So, when a Pull request is created we would want a CI Pipeline to be started right? The PipelineRun to start that Pipeline will be added in TriggerTemplate.
> TriggerBinding <
specifies the fields in the event payload from which you want to extract data and the fields in your corresponding TriggerTemplate
to populate with the extracted values.
Let’s say we setup triggers for a GitHub Reposiory, then the event coming from it will contain a lot of information such as commit sha, author and other. And if we want to pass this information to our Pipeline then we extract it from the event using TriggerBinding.
> EventListener
<
We have defined what we want to trigger i.e PipelineRun/TaskRun in TriggerTemplate and the information we want to fetch from event in TriggerBinding but who will do this? who will listen to events? process them? Well EventListeners.
EventListener receives an event, it executes a specified TriggerBinding
and TriggerTemplate
> Interceptor <
a “catch-all” event processor for a specific platform that runs before the TriggerBinding
enabling you to perform payload filtering, verification (using a secret), transformation, define and test trigger conditions, and other useful processing. Once the event data passes through an interceptor, it then goes to the Trigger
before you pass the payload data to the TriggerBinding
.
NOTE: In this article, all the features of TektonTriggers are not discussed, please refer documentation here to know more.
Let’s understand the flow…
When we setup Triggers for a Repository,
- EventListener receives an event
- Interceptors filter out events, validate them and pass them to trigger binding.
- Information from event payload is fetched which is described in TriggerBinding and added to TriggerTemplate
- The resource PipelineRun/TaskRun defined in TriggerTemplate is created.
Now, that we know the concepts in next part let’s create a Pipeline for a web App and setup Triggers for it.
NEXT:
PREV: