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

标签 jenkins multibranch-pipeline

我已经在 J​​enkins 中设置了许多多分支管道作业(运行 2.46.2 LTS、Branch API 2.0.8、GitHub Branch Source 2.0.5 和 Pipeline Multibranch 2.14),并且刚刚注意到分支索引 -因此,对旧分支的任何清理似乎都不是由来自 GitHub 的 webhook 调用触发的。仅当有人手动单击“立即扫描存储库”链接,或者重新保存 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 推送),但我的索引日志上的时间戳似乎与此不符。

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

最佳答案

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

关于jenkins - 多分支管道作业的分支索引是否应该由 webhook 自动触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43895588/

相关文章:

jenkins - 从管道共享库内部执行 shell 命令

docker - 使用最新的 Jenkins 创建docker镜像

android - 在 Jenkins 上使用 Retrolambda 构建失败

Jenkins 多分支管道不安排标记作业

jenkins - "polling ignores commits with certain messages"不适用于多分支管道

jenkins - 在具有相同工作空间的同一节点中并行运行多个阶段

memory - Docker容器的CPU和内存利用率

jenkins - 如何在多分支管道项目中为每个分支级别的用户提供访问权限?

jenkins - 如何在 Jenkins 多分支管道中安排具有特定参数的作业

jenkins - 如何获取 git 最新提交消息并阻止 jenkins 构建(如果提交消息包含 [ci Skip])?