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:
我设置了本地主机Jenkins,使用ngrok将我的Jenkins暴露给GitHub。我没有设置任何凭据。当我测试从WebHook发送时,它显示302找不到。答复:
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,
.....
}
更多回答
优秀答案推荐
Just got hit by the same issue. It appears that you are using the url:
http://056b05cb.ngrok.io/github-webhook
刚刚被同样的问题打击了。您似乎正在使用URL:http://056b05cb.ngrok.io/github-webhook
Simply switch it to http://056b05cb.ngrok.io/github-webhook/ (notice the trailing /
)
只需将其切换为http://056b05cb.ngrok.io/github-webhook/(请注意后面的/)
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.
如果你在浏览器上点击不带/的URL,它将得到302,浏览器将简单地重定向。但网络挂钩不遵循重定向,所以它只告诉你响应是什么,这是一个302重定向。
Please edit your hook jenkins with https://domain/github-webhook/
请使用https://domain/github-webhook/编辑您的钩子Jenkins
Notice the trailing / in the last url
due to "/" it will throw HTTP status code 302 error, please removed old web-hook and add new one with "/"
由于“/”将抛出HTTP状态代码302错误,请删除旧的Web挂钩并添加带有“/”的新挂钩
Example : http://3.131.67.206:8080/github-webhook/
示例:http://3.131.67.206:8080/github-webhook/
更多回答
It was exactly my issue! Thank you!
这正是我的问题!谢谢大家!
Jesus, what a nasty one. Thanks for this. I was scratching my head for a while
天哪,真是个恶心的家伙。谢谢你给我这个。我挠了一会儿头。
Thanks for pointing it out! Wish it was documented better on jenkins/github integration side!
谢谢你的指点!希望在Jenkins/GitHub集成方面有更好的记录!
Damn. The guide I was going though had the slash too. Me: nahh I don't need it. smh.
该死的。我要去的那个导游也有斜杠。我:不,我不需要。SMH。
Thank god I found this answer before I spent hours trying to figure this out!
谢天谢地,我在花了几个小时试图弄清楚这个问题之前就找到了这个答案!
我是一名优秀的程序员,十分优秀!