openshift-labs / starter-guides

Getting Started with OpenShift for Developers workshop
https://openshift-labs.github.io/starter-guides-html/
Apache License 2.0
136 stars 147 forks source link

OCP 4.8 Java lab - trigger not working #200

Open mandibuswell opened 2 years ago

mandibuswell commented 2 years ago

I tried the current 4.6 lab with the amended pipeline and trigger yamls for 4.7 on a 4.8 install and everything worked except the trigger step. I used this GIST to accelerate through https://gist.github.com/mandibuswell/c1d3d61f9413cf849146ca6e1798b4eb

[mbuswell-redhat.com@bastion agnosticd]$ oc create -f https://raw.githubusercontent.com/openshift-roadshow/nationalparks/master/pipeline/nationalparks-triggers.yaml
triggertemplate.triggers.tekton.dev/nationalparks created
triggerbinding.triggers.tekton.dev/nationalparks created
route.route.openshift.io/el-nationalparks created
Error from server (BadRequest): error when creating "https://raw.githubusercontent.com/openshift-roadshow/nationalparks/master/pipeline/nationalparks-triggers.yaml": admission webhook "webhook.triggers.tekton.dev" denied the request: mutation failed: cannot decode incoming new object: json: unknown field "name"

In addition of course, the imagery will need updating.

mandibuswell commented 2 years ago

I have confirmed that by setting the name to ref in template this works

---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
  name: nationalparks
spec:
  params:
  - name: git-repo-url
    value: $(body.repository.clone_url)
  - name: git-repo-name
    value: $(body.repository.name)
  - name: git-revision
    value: $(body.after)
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: EventListener
metadata:
  name: nationalparks
spec:
  serviceAccountName: pipeline
  triggers:
  - bindings:
    - ref: nationalparks
    template:
      **ref: nationalparks**
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  labels:
    app.kubernetes.io/managed-by: EventListener
    app.kubernetes.io/part-of: Triggers
    eventlistener: nationalparks
  name: el-nationalparks
spec:
  port:
    targetPort: http-listener
  to:
    kind: Service
    name: el-nationalparks
    weight: 100