For a comprehensive understanding of TriggerTemplates, including their architecture, advantages, and underlying principles, see the In-Depth Understanding of TriggerTemplate document.
A TriggerTemplate is a resource used to define a blueprint for resources that can be instantiated and executed, such as TaskRun or PipelineRun, when the EventListener detects an event. It offers parameterization capabilities, allowing you to use these parameters anywhere within the resource template.
TriggerTemplate currently supports the following Tekton Pipelines resources:
v1beta1 Resource Type | Description |
---|---|
Pipeline | Pipeline definition |
PipelineRun | Pipeline run instance |
Task | Task definition |
TaskRun | Task run instance |
Here is a typical example of a TriggerTemplate definition:
Define parameters in spec.params
:
Use parameters within the resource template:
$(tt.params.parameter_name)
$(tt.params.gitrevision)
Parameters in a TriggerTemplate only support string type values. Each parameter includes the following fields:
name
: Parameter name (required)description
: Parameter description (optional)default
: Default value, must be a string (optional)Note: Although parameter values can only be strings, you may include formatted content (such as JSON strings) within the string, and parse it during usage.
When passing JSON data, you need to handle it as a string:
Parameter Naming and Organization
Template Design
Error Handling
Parameter Parsing Errors
Resource Creation Failures
Naming Conflicts