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

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

问题描述

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



我会看到从github到达的POST詹金斯服务器,但什么也不会发生。访问日志报告返回给github的400错误。



为了找出返回的内容,我将tcpdump放在端口上。我现在看到Jenkins正在返回Error 400 Hook应该包含事件类型。它可以返回所有仓库事件。



我可以用tcpdump捕获github POST负载,但还没有完成。



我现在唯一的猜测是,我们的Github Enterprise安装版本比Jenkins github插件的预期更早。

更新:作为一个实验,在Github上,我将服务(Jenkins github plugin)的调用改为Webhook,但使用相同的URL MY_JENKINS / github-webhook /。这成功了,被github插件成功解析,并触发正在监视项目/分支的作业。

Github Enterprise应该有内置的webhook功能,所以当你说你在Github上安装服务时,我有点不确定你的意思。



你可以设置新的webhooks转到以下标签:

  https://github-enterprise.com/my-org/myrepo >>设置>> Webhooks&服务

以下是截图:



另一个要检查的地方是Jenkins中的设置,以确保它设置为与Github一起工作。

  Jenkins>>管理Jenkins>>配置系统>>查找:GitHub插件配置


在这里,您需要提供您的Github的证书以及Github api url:

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



可能会取消选中'Custom Github API URL',但我还没有取得很好的成功。)



以下是截图:



'Credentials'是来自Github的访问令牌。

  Github>>个人设定>>个人存取令牌

我已经完成这样的设置已经有一段时间了,所以随时纠正我,如果我错了什么。


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.

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.

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.

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

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.

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 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.

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:

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

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

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


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

Here is a screenshot:

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“钩子应该包含事件类型”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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