Search code examples
openshifttektontekton-pipelines

How to set up a generic webhook trigger in Tekton


I want to set up a webhook trigger in tekton. In the documentation, I can find Github, Gitlab and bitbucket triggers available. But I want a generic webhook that processes HTTP POST and reads the JSON body.

For example: I am doing the following with Jenkins' generic webhook trigger.

Prometheus Alertmanager sends a HTTP POST to Jenkins' Generic webhook and Jenkins processes the JSON body and kicks off the build.

I want to the same with Tekton. Alertmanager sends a HTTP POST to the Tekton webhook and it would process the JSON body and kick off the build.

Is this doable with Tekton's webhook trigger? Is this not available yet in tekton or am i missing something form the documentation?

If someone has already done this, can you point me in the right direction? I am using openshift 4.5


Solution

  • Yes, this should work fine.

    You create an EventListener - this spins up a Deployment and a Service that you somehow has to expose, e.g. using a Route on OpenShift or Ingress in Kubernetes - and that is the url that your Prometheus Alertmanager should send it's POST request to.

    Also create a TriggerBinding where you can declare jsonPaths to retrieve data from your JSON-payload into parameters.

    And finally you need a TriggerTemplate to declare what Tekton resource your trigger should create, for each event, typically a PipelineRun and you should declare how you should map the params from your TriggerBinding to the params in your PipelineRun.