HTTP 错误 400 访问 /github-webhook/。挂钩应包含事件类型

HTTP error 400 accessing /github-webhook/. Hook should contain event type

我从 Gitlab 调用 webhook Jenkins 并得到以下错误:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Error 400 Hook should contain event type</title>
    </head>
    <body>
        <h2>HTTP ERROR 400</h2>
        <p>Problem accessing /github-webhook/. Reason:

            <pre>    Hook should contain event type</pre>
        </p>
        <hr>
        <i>
            <small>Powered by Jetty://</small>
        </i>
        <hr/>
    </body>
</html>

我做了什么?我在这里阅读了参考资料但没有工作:

为什么我又问类似的标题:

因为上面的解决方案对我仍然不起作用。

我能确定的是:

我确定 Jenkins 可以连接到 Gitlab,因为我可以手动构建项目 "X" 并且没有错误。当我想在推送到 gitlab 时自动构建时,我的问题就在这里,但我总是会收到该错误。谁能帮帮我?

您似乎在使用 GitLabGitHub 插件的 webhook (http://jenkins.example.com/github-webhook/)。

您应该改用这些 Webhook 之一(假设您可以安装 GitLab Hook Plugin):

  • http://jenkins.example.com/gitlab/notify_commit
  • http://jenkins.example.com/gitlab/build_now

参考:https://github.com/jenkinsci/gitlab-hook-plugin#build-now-hook