jenkinsci / gogs-webhook-plugin

Jenkins Gogs Webhook
https://plugins.jenkins.io/gogs-webhook/
MIT License
79 stars 42 forks source link

Webhook doesn't work without a password/secret #18

Closed slPerryRhodan closed 7 years ago

slPerryRhodan commented 7 years ago

Gogs Version (Docker Tag): 0.10.8 Jenkins Plugin Version: 1.0.9 Reference: #https://github.com/gogits/gogs/issues/4269

Hello,

I'm forced to use a password/secret when I want to use Webhooks of Gogs, otherwise the Jenkins plugin (1.0.9) throws an exception:

javax.servlet.ServletException: net.sf.json.JSONException: JSONObject["secret"] not found.
....
Caused by: net.sf.json.JSONException: JSONObject["secret"] not found.
    at net.sf.json.JSONObject.getString(JSONObject.java:2040)
    at org.jenkinsci.plugins.gogs.GogsWebHook.doIndex(GogsWebHook.java:163)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:335)
    at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:175)
    at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:108)
    at org.kohsuke.stapler.IndexDispatcher.dispatch(IndexDispatcher.java:26)
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)
    ... 60 more

Since Gogs 0.10.x there is no JSON field "secret" anymore, only the header field "X-Gogs-Signature" will be send, which holds the encrypted secret or it is just empty. I guess the back-support for Gogs version 0.9.x and less causes the issue.

Anyway, older versions of "Gogs 0.9.x" are working fine together with the Jenkins plugin "1.0.9" or less. But I would appreciate, if you could fix this issue. Or is there any additional configuration I have to do?

willemvd commented 7 years ago

In the Gogs thread I see that the X-Gogs-Signature field could be empty. Is this correct? Can a user disable this header to be filled? Maybe for @Unknwon ?

unknwon commented 7 years ago

@willemvd empty means user didn't set secret.

willemvd commented 7 years ago

@Unknwon thanks