jenkinsci / generic-webhook-trigger-plugin

Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
https://plugins.jenkins.io/generic-webhook-trigger
404 stars 159 forks source link

Two webhook POSTs only trigger one job despite unique parameter values #197

Closed gongsu832 closed 3 years ago

gongsu832 commented 3 years ago

Jenkins version: 2.263.1 Generic Webhook Trigger Plugin version: 1.72

I have a freestyle job setup to receive webhook POSTs from github. When a pull request is merged, two webhook events are POSTed, one is a pull_request event with the payload {"action": "closed", ...} and the other is a push event with the payload {"ref": "refs/heads/master", ...}. I have followed the document to make the job parameterized and use the X-GitHub-Delivery UUID in the POST header for the unique value. However, I still only get one job triggered which shows two UUIDs in the console output:

Github Webhook Event bec5aa10-5489-11eb-9c9f-0b787ea43d19 [pull_request]
Github Webhook Event befb3d4c-5489-11eb-9930-dc17b5ea3fcd [push]
Running as SYSTEM
GenericWebhookEnvironmentContributor
 Received:

{"action":"closed", ...}

and the {"ref": "refs/heads/master", ...} payload is lost.

tomasbjerre commented 3 years ago

Can you supply your full configuration? A screenshot showing the parameters and the plugin configuration. Or Job DSL would also work if that is what you are using.

gongsu832 commented 3 years ago

@tomasbjerre here is the capture of my job configuration. Thanks. jenkins-merge Config [Jenkins].pdf

tomasbjerre commented 3 years ago

It is because none of the resolved variables from this plugin are being resolved to variable with name of the parameter: github_webhook_uuid

You only resolve:

gongsu832 commented 3 years ago

Ahh, thought the parameter name could be arbitrary as long as its default value gets resolved. Changing github_webhook_uuid to x_github_delivery worked. I now get two triggers. Thanks!

BTW, I have another problem. I created a secret text credential for the "Token Credential" using the "Add" button next to it. But in the pull-down menu nothing shows up so I cannot select the credential (see the attached screenshot). I thought it might be a browser problem so I tried chrome, firefox, and safari but they all behave the same.

Screen Shot 2021-01-14 at 12 58 09 AM

tomasbjerre commented 3 years ago

Ok good! The credentials thing should be its own issue.