gpt4 book ai didi

git - 在 Jenkins 多分支管道上触发重复构建

转载 作者:太空狗 更新时间:2023-10-29 13:10:07 33 4
gpt4 key购买 nike

我们看到在 Jenkins 多分支管道项目上触发了重复构建。通常使用此插件使用来自 Bitbucket 的推送通知触发构建:https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview

但是,出于某种原因,我们现在看到了“双重”构建。如果您查看触发的 2 个构建,一个由“提交通知”触发,另一个由“分支索引”触发。

是什么导致了分支索引,为什么会触发构建?我们没有添加或删除分支,这只是正常的提交/推送。

更复杂的是,它并不是一直都在发生。有一次我认为它只发生在 merge 之后,但事实并非如此。此外,停止它的一种方法似乎是删除作业的构建历史记录(这显然不理想)。

我们正在通过管道脚本设置作业的属性,但只是为了丢弃旧版本:

properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '20'))])

另一个混淆来源似乎是是否应该启用轮询(没有间隔)以便推送通知对 Git 插件起作用。 Git 插件的文档表明这是必需的,而且似乎确实适用于“正常”管道构建,但似乎不需要多分支管道构建。 这是正确的吗?来自 Jenkins Git 插件 wiki:

This will scan all the jobs that:

Have Build Triggers > Poll SCM enabled. No polling Schedule is required. Are configured to build the repository at the specified URL Are configured to build the optionally specified branches or commit ID For jobs that meet these conditions, polling will be immediately triggered. If polling finds a change worthy of a build, a build will in turn be triggered.

我们正在使用 Bitbucket 4.8.4 和 Jenkins 2.30(以及所有最新的管道插件)。

最佳答案

正如其他答案已经建议的那样,“不允许并发构建”选项就是您想要的。您可以通过 Jenkinsfile 获取:

 properties ([
buildDiscarder(logRotator(artifactNumToKeepStr: '5', daysToKeepStr: '15')),
disableConcurrentBuilds()
])

编辑:

这不是这里实际问题的解决方案。但它对某些人来说似乎仍然有帮助,所以只要我们没有更好的答案,我就会离开它。

关于git - 在 Jenkins 多分支管道上触发重复构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40633735/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com