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

Not accept Content-Type with charset #226

Closed h3nrique closed 2 years ago

h3nrique commented 2 years ago

Not accept Content-Type with charset

A Curl command to simulate

curl -v -H "Content-Type: application/json; charset=UTF-8" -X POST -d '{ "app":{ "name":"GitHub API", "url":"http://developer.github.com/v3/oauth/" }}' http://localhost:8080/jenkins/generic-webhook-trigger/invoke?token=sometoken

Jenkins output log

jenkins_1  | 2021-12-22 21:39:15.876+0000 [id=480]      WARNING h.i.i.InstallUncaughtExceptionHandler#handleException: Caught unhandled exception with ID a9d6fff4-bc76-47ca-af0f-1734ee61581d
jenkins_1  | java.lang.RuntimeException: Unsupported content type: application/json; charset=UTF-8
jenkins_1  |    at org.jenkinsci.plugins.gwt.GenericWebHookRequestReceiver.getPostContentAsJson(GenericWebHookRequestReceiver.java:104)
jenkins_1  |    at org.jenkinsci.plugins.gwt.GenericWebHookRequestReceiver.doInvoke(GenericWebHookRequestReceiver.java:69)

I used docker-compose to install latest version of plugin and simulate.

version: "3"
services:
  jenkins:
    image: jenkins/jenkins:lts-jdk11
    environment:
      TZ: America/Fortaleza
    ports:
      - 8080:8080
      - 50000:50000
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/docker-data/jenkins:/var/jenkins_home

I identified this problem when configure Azure Web Hooks, by default it's including "; charset=UTF-8" and it's not possible remove or change. image

tomasbjerre commented 2 years ago

Thanks for reporting. Released a fix now in 1.79. Open issue again if not working.

h3nrique commented 2 years ago

Work like a charm. Thanks beast!!

image