Xiaoxi Bian
Xiaoxi Bian

Reputation: 389

Github Webhook With Jenkins return 302 Found

I set up localhost jenkins, using ngrok to expose my jenkins to github. I didn't set up any credentials. When I test delivery from webhook, it shows 302 not found. Response:

Content-Length: 0
Date: Mon, 16 Apr 2018 02:09:22 GMT
Location: http://056b05cb.ngrok.io/github-webhook/
Server: Jetty(9.4.z-SNAPSHOT)
X-Content-Type-Options: nosniff

Request:

Headers
Request URL: http://056b05cb.ngrok.io/github-webhook
Request method: POST
content-type: application/json
Expect: 
User-Agent: GitHub-Hookshot/d5b13bc
X-GitHub-Delivery: bdc31e52-4115-11e8-9e6b-c7d083151290
X-GitHub-Event: push
Payload
{
  "ref": "refs/heads/master",
  "before": "14e1265dc10ef64c93ee7791db7fa9ccef63279f",
  "after": "1f51b991d10af7c2b8fb4bc4c44417a57cf7bb56",
  "created": false,
  "deleted": false,
  "forced": false,
  "base_ref": null,
  .....
}

Upvotes: 38

Views: 15767

Answers (4)

JDQ
JDQ

Reputation: 462

To add to the other answers, make sure you're adding the trailing slash to your Webhook settings in GitHub (it may or not be important to also ensure that there is a trailing slash in you Jenkins instance settings, but the default value does have one).

Upvotes: 0

vishal sharma
vishal sharma

Reputation: 190

due to "/" it will throw HTTP status code 302 error, please removed old web-hook and add new one with "/"

Example : http://3.131.67.206:8080/github-webhook/

Upvotes: 1

Le Phu Cuong
Le Phu Cuong

Reputation: 51

Please edit your hook jenkins with https://domain/github-webhook/

Notice the trailing / in the last url

Upvotes: 5

bigosmallm
bigosmallm

Reputation: 1196

Just got hit by the same issue. It appears that you are using the url: http://056b05cb.ngrok.io/github-webhook

Simply switch it to http://056b05cb.ngrok.io/github-webhook/ (notice the trailing /)

If you hit the url without the / on a browser, it will get a 302 and the browser will simply redirect. But the webhook does not follow redirects, so it simply tells you what the response was, which was a 302 redirect.

Upvotes: 104

Related Questions