多分支管道作业的分支索引是否应该由 webhooks 自动触发?

Should branch indexing for Multibranch Pipeline jobs be triggered automatically by webhooks?

我在 Jenkins 中设置了多个多分支管道作业(运行ning 2.46.2 LTS,Branch API 2.0.8,GitHub Branch Source 2.0.5 , 和 Pipeline Multibranch 2.14) 并且刚刚注意到分支索引——以及因此对旧分支的任何清理——似乎不会被来自 GitHub 的 webhook 调用触发。只有当有人手动单击“立即扫描存储库”link,或者如果 Jenkins 中的作业配置被重新保存时,它才会被触发。我使用“扫描存储库日志”页面中显示的时间戳作为分支索引发生时间的指示。

似乎正确检测并构建了新分支或对现有分支的更改,因此来自源代码管理 (GitHub) 的 webhook 正在运行,但令人惊讶的是这并没有触发分支索引,从而清理旧分支。我只是无法从 documentation 判断这是正确的和预期的行为,还是我的设置有问题。

我注意到“如果没有其他情况则定期 运行”设置的帮助文本说:

Some kinds of folders are reindexed automatically and immediately upon receipt of an external event. For example, a multi-branch project will recheck its SCM repository for new or removed or modified branches when it receives an SCM change notification. (Push notification may be configured as per the SCM plugin used for each respective branch source.) Such notifications can occasionally be unreliable, however, or Jenkins might not even be running to receive them. In some cases no immediate notification is even possible, for example because Jenkins is behind a firewall and can only poll an external system.

This trigger allows for a periodic fallback, but when necessary. If no indexing has been performed in the specified interval, then an indexing will be scheduled. For example, in the case of a multi-branch project, if the source control system is not configured for push notification, set a short interval (most people will pick between 15 minutes and 1 hour). If the source control system is configured for push notification, set an interval that corresponds to the maximum acceptable delay in the event of a lost push notification as the last commit of the day. (Subsequent commits should trigger indexing anyway and result in the commit being picked up, so most people will pick between 4 hours and 1 day.)

这当然意味着多分支管道作业的索引应该由分支事件重新触发(例如,通过 webhook 从 GitHub 推送),但我的索引日志上的时间戳似乎与此不符。

那么,我观察到的是预期行为吗?如果是这样,并且我想定期清理旧分支,我是否需要 select “扫描存储库触发器”下的“如果不是,则定期 运行”复选框?还是我的设置有问题,导致它无法按预期工作?

我依赖 "Periodically if not otherwise run" 来 1) 清理分支和 2) 为全新的存储库创建容器作业(我使用 "Bitbucket Team/Project","Github Organization" 的 bitbucket 版本,它基本上为您组织中的每个回购创建一个多分支管道)。我将 "Periodically if not otherwise run" 设置为 运行 每个项目每天一次。

这些东西似乎可以通过 webhook 工作,但根据我的经验,它们不会。

根据 official documentation:

By default, Jenkins will not automatically re-index the repository for branch additions or deletions (unless using an Organization Folder), so it is often useful to configure a Multibranch Pipeline to periodically re-index in the configuration.