简体   繁体   English

Jenkins:Github webhook 不会触发任何工作

[英]Jenkins: Github webhook does not trigger any job

I try to configure Jenkins.我尝试配置詹金斯。 I want a simple behavior: trigger a build on new pull request.我想要一个简单的行为:在新的拉取请求上触发构建。

I cannot understand what I missed...我无法理解我错过了什么......

Jenkins version: 2.89.2詹金斯版本:2.89.2

At https://ci.mysite.fr/configure :https://ci.mysite.fr/configure

在此处输入图片说明

Still no build triggered:仍然没有触发构建:

在此处输入图片说明

At https://ci.mysite.fr/job/test-back/configure :https://ci.mysite.fr/job/test-back/configure 在此处输入图片说明

On Github, Webhook is sent and well received by Jenkins:在 Github 上,Webhook 被 Jenkins 发送并受到好评:

在此处输入图片说明

Nginx Log says the same: Nginx 日志也这么说:

在此处输入图片说明

Help please!请帮助!

Some things to check when debugging this sort of thing:调试此类事情时要检查的一些事项:

  • Check your Jenkins logs to see whether or not Jenkins is receiving the hook and deciding not to take action for some reason.检查您的 Jenkins 日志以查看 Jenkins 是否收到钩子并因某种原因决定不采取行动。
  • Check Jenkins security by clicking Manage Jenkins -> Configure Global Security.通过单击管理 Jenkins -> 配置全局安全性来检查 Jenkins 安全性。 Open things up as much as you're comfortable doing and see if that changes anything.尽可能多地敞开心扉,看看这是否会改变任何事情。
  • Ensure that you're pushing changes to the master branch.确保您将更改推送到主分支。 For simplification, consider using ** as your branch specifier while you're getting this to work.为简化起见,请考虑使用 ** 作为您的分支说明符,而您正在使用它。
  • Ensure Git is properly configured on your Jenkins host by clicking Manage Jenkins -> Global Tool Configuration通过单击管理 Jenkins -> 全局工具配置,确保在您的 Jenkins 主机上正确配置了 Git
  • Make sure the user whose credentials you provided can manage hooks and pull from the repo you're interested in.确保您提供凭据的用户可以管理挂钩并从您感兴趣的存储库中提取。
  • Run the job manually in Jenkins, ensure that it works.在 Jenkins 中手动运行作业,确保它工作正常。
  • After you run the job, it should show up as an option in Protected Branches/Required Statuses.运行作业后,它应该显示为受保护分支/必需状态中的一个选项。 In your repo, click on Settings->Branches, select your branch in the Branches section, click Require Status Check to Pass before merging option, and your job should show up in the list which appears.在你的 repo 中,点击 Settings->Branches,在 Branches 部分选择你的分支,点击 Require Status Check to Pass before merging 选项,你的工作应该出现在出现的列表中。

Webhooks are arguably the most difficult Jenkins feature to test without prior experience, because of gotchas like these (probably their list is incomplete): Webhooks 可以说是 Jenkins 最难在没有经验的情况下测试的功能,因为这样的问题(可能他们的列表不完整):

  1. New git commit / git push must be made for each pipeline build (repeating a previous one won't trigger a new build even if webhooks are already set up correctly - see below).必须为每个管道构建进行新的git commit / git push (即使 webhooks 已经正确设置,重复前一个也不会触发新构建 - 见下文)。

  2. First build made after setting up webhook correctly must be manual (no bootstrap from the webhook itself is possible).正确设置 webhook 后进行的第一次构建必须是手动的(不能从 webhook 本身进行引导)。

  3. First build made after setting webhook correctly must succeed completely for the changes to take effect and for webhooks to start working.正确设置 webhook 后进行的第一次构建必须完全成功,更改才能生效并让 webhook 开始工作。 This will also cause Jenkins to miss all incoming requests made during the first build of a newly created pipeline.这也会导致 Jenkins 错过在新创建的管道的第一次构建期间发出的所有传入请求。


More info更多信息

  1. Please be warned that it is not possible to trigger a build using the same build conditions again (at least using a webhook).请注意,不可能再次使用相同的构建条件触发构建(至少使用 webhook)。 Therefore you might have a correct webhook setup already, but not find out that it works unless you create a new git commit and push it to the remote repo on Github.因此,您可能已经有了正确的 webhook 设置,但除非您创建一个新的 git commit 并将其推送到 Github 上的远程存储库,否则不会发现它有效。 If your try to repeat some old push over and over again, by simply pressing the "Redeliver" button in the Recent deliveries section on Github's Webhooks / Manage webhook page, Jenkins will never move beyond the "poke" repo stage, as it requires SCM changes to be detected in order to trigger a new build:如果您尝试一遍又一遍地重复一些旧的推送,只需在 Github 的 Webhooks / 管理 webhook 页面上的“最近交付”部分中按“重新交付”按钮,Jenkins 将永远不会超出“戳”回购阶段,因为它需要 SCM要检测的更改以触发新构建:
Received PushEvent for https://github.com/mirekphd/<REPO_NAME> from <GITHUB_IP> ⇒ <JENKINS_URL>/github-webhook/

Apr 16, 2021 9:42:12 PM INFO org.jenkinsci.plugins.github.webhook.subscriber.DefaultPushGHEventSubscriber$1 run
Poked <REPO_NAME>

Apr 16, 2021 9:42:13 PM INFO com.cloudbees.jenkins.GitHubPushTrigger$1 run
SCM changes detected in <REPO_NAME>. Triggering #236

For further info on points 2) and 3): see original source .有关第 2) 和 3) 点的更多信息:请参阅原始来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM