在Jenkins多分支管道上触发重复的构建 [英] Duplicate builds triggered on Jenkins multibranch pipeline

查看:960
本文介绍了在Jenkins多分支管道上触发重复的构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



然而, ,由于某种原因,我们现在看到了双重构建。如果您查看触发的2个构建版本,其中一个由提交通知触发,另一个由Branch Indexing引发。

什么是导致分支索引,为什么它触发构建?我们不添加或删除分支,这只是一个正常的提交/推送。 为了使它更复杂,它不会发生所有时间。有一次,我认为这只发生在合并后,但事实并非如此。另外,阻止它的一种方法似乎是删除作业的构建历史记录(这显然不是理想的)。



我们正在设置作业的属性管道脚本,但只是放弃旧的构建:

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

如果应该启用轮询(无间隔)以便推送通知为Git插件工作。 Git插件的文档表明这是必需的,确实看起来是用于'普通'管道构建,但似乎并不需要多分支管道构建。 这是否正确? 来自Jenkins Git Plugin wiki:
$ b


所有这些工作:

具有生成触发器>启用了轮询SCM。没有轮询时间表是
所需的。配置为在指定的URL中构建存储库
配置为构建可选的指定分支或提交ID
对于满足这些条件的作业,轮询将立即触发
。如果轮询发现值得构建的变化,则构建将依次触发

我们使用Bitbucket 4.8 .4和Jenkins 2.30(以及所有最新的管道插件)。

解决方案

由于其他答案已经建议不允许并发构建选项就是你想要的。
您可以通过 Jenkinsfile 获得:

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

编辑:



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


We are seeing duplicate builds triggered on Jenkins multibranch pipeline projects. Builds are normally triggered using push notifications from Bitbucket using this plugin: https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview

However, we are now seeing 'double' builds for some reason. If you look at the 2 builds that are triggered, one is triggered by a 'commit notification', and the other is triggered by 'Branch Indexing'.

What is causing the branch indexing, and why is it triggering a build? We are not adding or deleting branches, it's just a normal commit/push.

To make it more complicated, it's not happening all the time. At one point I thought it was only happening after merges, but that's not the case. Also, one way to stop it seems to be by deleting the build history for a job (which obviously isn't ideal).

We are setting properties on the job from the pipeline script, but only to discard old builds:

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

Another source of confusion seems to be if one should have polling enabled (with no interval) in order for push notifications to work for the Git plugin. The documentation for the Git plugin indicates this is required, and indeed seems to be for 'normal' pipeline builds, but doesn't seem to be required for multibranch pipeline builds. Is this correct? From the Jenkins Git Plugin 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.

We are using Bitbucket 4.8.4 and Jenkins 2.30 (and all the latest pipeline plugins).

解决方案

As the other answer already suggested the "Do not allow concurrent builds" option is what you want. And you can get that via the Jenkinsfile:

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

EDIT:

This is not the solution for the actual problem here. but it still seems helpful to some people, so I'll leave it as long as we don't have a better answer.

这篇关于在Jenkins多分支管道上触发重复的构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆