Jenkins github插件返回错误400"挂钩应包含事件类型" [英] Jenkins github plugin returns error 400 "Hook should contain event type"

查看:139
本文介绍了Jenkins github插件返回错误400"挂钩应包含事件类型"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我公司,我们有一个Github Enterprise实例,使所有源代码保持一致,而Jenkins服务器则可以进行持续集成.我在Jenkins上使用Jenkins github插件,并在Github上安装了一个服务来调用MYJENKINS/github-webhook.

At my company we have a Github Enterprise instance keeping all of our source in line, and Jenkins servers to do continuous integration. I'm using the Jenkins github plugin on Jenkins, and installing a service on Github to call MYJENKINS/github-webhook.

我会看到POST从jenkins服务器上的github到达,但是什么也不会发生.访问日志报告一个400错误返回给github.

I would see the POSTs arriving from github on the jenkins server, but nothing would happen. The access log reports a 400 error being returned to github.

要找出返回的内容,我将tcpdump放在端口上.现在,我看到Jenkins返回错误400挂钩应包含事件类型".它将为所有存储库事件返回该值.

To find out what was being returned, I put tcpdump on the port. I now see that Jenkins is returning "Error 400 Hook should contain event type". It returns that for all repository events.

我可能可以使用tcpdump捕获github POST有效负载,但是还没有做到这一点.

I can probably capture the github POST payload with tcpdump, but haven't done that yet.

目前,我唯一的猜测是我们的Github Enterprise安装版本比Jenkins github插件预期的版本早.

My only guess at the moment is that our Github Enterprise installation is an earlier version than what is expected by the Jenkins github plug-in.

更新:作为一个实验,在Github上,我将调用从Service("Jenkins github插件")更改为Webhook,但使用相同的URL MY_JENKINS/github-webhook/.成功,由github插件成功解析,并触发监视项目/分支的作业.

Update: As an experiment, on Github, I changed the call from a Service ("Jenkins github plugin") to a Webhook, but using the same URL MY_JENKINS/github-webhook/. THAT succeeds, is parsed successfully by the github plugin, and triggers the jobs that are watching a project/branch.

推荐答案

Github Enterprise应该内置了Webhook功能,所以当您说要在Github上安装服务时,我有点不确定.

Github Enterprise should have webhook functionality built-in, so I'm a little unsure what you mean when you say you're installing a service on Github.

您可以通过转到以下标签来设置新的Webhooks:

You can set up new webhooks by going to the following tab:

https://github-enterprise.com/my-org/myrepo >> Settings >> Webhooks & services

以下是屏幕截图:

Here is a screenshot:

另一个要检查的地方是Jenkins中的设置,以确保将其设置为可与Github一起使用.

The other place to check is the settings in Jenkins, to make sure that it is set up to work with Github.

Jenkins >> Manage Jenkins >> Configure System >> Find: GitHub Plugin Configuration

在这里,您需要提供Github的凭据以及Github的api网址:

In here, you need to provide your credentials for Github as well as the Github api url:

https://<github-enterprise.com>/api/v3/


(您可以取消选中自定义Github API URL",但在此方面还没有取得很好的成功.)


(You might be able to leave the 'Custom Github API URL' unchecked, but I haven't had good success with that.)

这是屏幕截图:

凭据"将是来自Github的访问令牌.

The 'Credentials' would be an access token from Github.

Github >> Personal settings >> Personal access tokens

自从我完成这样的设置已经有一段时间了,所以如果我对任何事情有误,请随时纠正我.

It's been a while since I've done setup like this, so feel free to correct me if I'm wrong about anything.

这篇关于Jenkins github插件返回错误400&quot;挂钩应包含事件类型&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆