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

Support X-Gitlab-Token #186

Closed lopossumi closed 3 years ago

lopossumi commented 3 years ago

Hi, and first of all thanks for the great plugin!

Unfortunately we're currently limited to using Generic Webhook Trigger for a single job in Jenkins, as GitLab sends their webhook tokens in their own way:

Request headers:
Content-Type: application/json
X-Gitlab-Event: Push Hook
X-Gitlab-Token: MyToken

Would it be possible to try parsing the token also from this source, or is there a workaround?

Related issue in GitLab has been open for two years, so I'm not expecting it to resolve any time soon: Add ability to specify webhook authentication token header name

tomasbjerre commented 3 years ago

Released in 1.69. Open issue again if any problems!

lopossumi commented 3 years ago

Doesn't seem to work. I tested the post against a PostBin test server and it seems that the actual request header is written in lowercase (unlike what GitLab's own logs say), so that could be the reason:

Headers x-real-ip: 111.222.333.444 host: postb.in connection: close content-length: 1586 content-type: application/json x-gitlab-event: Push Hook x-gitlab-token: MyToken

tomasbjerre commented 3 years ago

Fixed in 1.70.

lopossumi commented 3 years ago

Works like a charm! Thanks! ⭐