我想有一个单一的事件监听器,将触发不同的管道基于git的回购名称
对于apiv1alpha1
,可以这样做:
apiVersion: triggers.tekton.dev/v1alpha1
kind: EventListener
metadata:
name: event-listener-yf57o5
spec:
serviceAccountName: pipeline
triggers:
- name: app1Trigger
bindings:
- kind: ClusterTriggerBinding
ref: github-push
interceptors:
- params:
- name: filter
value: body.repository.name.matches('app1name-')
ref:
kind: ClusterInterceptor
name: cel
template:
ref: trigger-template-app1-hh2im8
- name: app2trigger
bindings:
- kind: ClusterTriggerBinding
ref: github-push
interceptors:
- params:
- name: filter
value: body.repository.name.matches('app2name-')
ref:
kind: ClusterInterceptor
name: cel
template:
ref: trigger-template-app2-5yoj99
触发器模板可以像这样(for complete):
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
name: trigger-template-app2-5yoj99
spec:
params:
- name: git-revision
- name: git-commit-message
- name: git-repo-url
- name: git-repo-name
- name: content-type
- name: pusher-name
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: app2-pipeline-
labels:
tekton.dev/pipeline: app2-pipeline
spec:
params:
- name: APP_NAME
value: app2
- name: GIT_REPO
value: $(tt.params.git-repo-url)
- name: GIT_REVISION
value: $(tt.params.git-revision)
pipelineRef:
name: app2-pipeline
workspaces:
- name: workspace
volumeClaimTemplate:
metadata:
labels:
tekton.dev/pipeline: app2-pipeline
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi