Trigger 概述
Trigger指定事件监听器检测到事件时发生的情况。主要由TriggerTemplate、TriggerBinding和Interceptor组成。
TriggerTemplate定义在spec.template字段上,支持引用和内联两种定义方式。
TriggerBinding定义在spec.bindings字段上,支持引用和内联两种定义方式。
ClusterInterceptor可选,定义在spec.interceptors字段上。
Trigger CRD 资源规范
apiVersion: triggers.tekton.dev/v1beta1
kind: Trigger
metadata:
name: trigger
spec:
serviceAccountName: # (可选)指定要提供给 EventListener 以实例化/执行目标资源的 ServiceAccount。
interceptors: # (可选)指定一个或多个Interceptors,用于在将有效负载数据传递到 TriggerTemplate 之前对其进行处理
- ref:
name: "cel"
params:
- name: "filter"
value: "header.match('X-GitHub-Event', 'pull_request')"
- name: "overlays"
value:
- key: extensions.truncated_sha
expression: "body.pull_request.head.sha.truncate(7)"
bindings: # (可选)指定字段绑定列表;每个绑定可以引用现有的 TriggerBinding 或使用name/value对嵌入 TriggerBinding 定义
- ref: pipeline-binding
template: # 指定相应的 TriggerTemplate 作为嵌入 TriggerTemplate 定义的引用。
ref: pipeline-template
Trigger 示例
apiVersion: triggers.tekton.dev/v1beta1
kind: Trigger
metadata:
name: trigger
spec:
interceptors:
- ref:
name: "cel"
params:
- name: "filter"
value: "header.match('X-GitHub-Event', 'pull_request')"
- name: "overlays"
value:
- key: extensions.truncated_sha
expression: "body.pull_request.head.sha.truncate(7)"
bindings:
- ref: pipeline-binding
template:
ref: pipeline-template
参考文档
https://tekton.dev/docs/triggers/triggers/
标签:name,value,spec,Tekton,Trigger,CRD,ref,TriggerTemplate From: https://www.cnblogs.com/wangguishe/p/17877568.html