Jenkins多分支管道未安排标签作业 [英] Jenkins Multi-branch pipeline doesn't schedule tag jobs

查看:148
本文介绍了Jenkins多分支管道未安排标签作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让詹金斯(Jenkins)的多分支管道工作来以类似于分支的方式构建标签.在Jenkins 2.73(不确定何时添加功能)中,可以将Multibranch项目配置为从源存储库中检索分支和标签.最初,我认为这对我的需求来说是完美的(我的Jenkinsfile现在可以在Jenkins的同一位置进行开发或生产了). 配置了标签发现功能的多分支作业

I'm trying to get Jenkins' multibranch pipeline job to build tags in a similar manner to branches. In Jenkins 2.73 (not sure when the functionality was added), Multibranch projects can be configured to retrieve both branches and tags from the source repository. Initially I thought this would be perfect for my needs (my Jenkinsfile can now build development or production builds from the same place in Jenkins). Multibranch job with tags discovery configured

我使用脚本管道成功构建并运行了自己的过程,但是我的问题是,尽管分支作业完美地捕获了我的触发器(每周Cron),因此可以使用Git插件的notifyOnCommit功能进行触发(使我能够每周清理一次构建,但也可以通过回购扫描webhook来对回购进行提交),而标记构建则不会.

I have the build process itself up and running quite happily with a scripted pipeline, however my issue is that whilst the branch jobs pickup my triggers perfectly (Cron weekly) and are thus triggerable using the Git plugin's notifyOnCommit functionality (allows me to clean build weekly, but build on commit to the repo as well via a repo scan webhook), tag builds do not.

还有其他人遇到吗?如果是这样,您找到任何合理的方法来解决它了吗?

Has anyone else come across this? If so, have you found any reasonable way to resolve it?

脚本化管道中的相关代码段(我尝试使用和不使用overrideIndexTriggers设置): properties( [ pipelineTriggers( triggers: [ cron('H 02 * * 7') ] ), overrideIndexTriggers(true) ] )

Relevant snippet from my scripted pipeline (I tried with and without the overrideIndexTriggers setting): properties( [ pipelineTriggers( triggers: [ cron('H 02 * * 7') ] ), overrideIndexTriggers(true) ] )

由多分支管道生成的分支作业进行轮询配置似乎很好 多分支流水线从标签生成的作业没有收到相同的配置,奇怪的是...

Polling configuration from a branch job generated by the multibranch pipeline seems fine Jobs generated from tags by the multibranch pipeline do not receive the same configuration, bizarrely...

在多分支流水线扫描日志中有一条注释表明,标记永远不会被自动调度: Processed 8 branches Checking tags... Checking tag testing ‘Jenkinsfile’ found Met criteria No automatic builds for testing Processed 1 tags [Mon Oct 23 09:55:00 UTC 2017] Finished branch indexing. Indexing took 8.1 sec Finished: SUCCESS

There is a note in the multibranch pipeline scan log that suggests that Tags will never be auto-scheduled: Processed 8 branches Checking tags... Checking tag testing ‘Jenkinsfile’ found Met criteria No automatic builds for testing Processed 1 tags [Mon Oct 23 09:55:00 UTC 2017] Finished branch indexing. Indexing took 8.1 sec Finished: SUCCESS

我的项目是基于docker的,我想每周运行一个发布版本,以获取任何基础图像更改等.

My project is docker based and I would like to run a release build weekly, to pull in any base-image changes etc.

有人对我可以做什么来使多分支项目计划标签构建有任何想法吗?

Does anyone have any ideas about what I can do to get multi-branch projects to schedule tag builds?

推荐答案

根据

Not automatically triggering a build for discovered tags seems to be by design according to JENKINS-47496. Stephen Connolly offers an explanation and suggestion for what you might do:

Stephen Connolly添加了评论-6天前

Stephen Connolly added a comment - 6 days ago

默认情况下不构建标签(因为否则,在签出存储库时可能会遇到构建风暴),更糟糕的是,将内置订单标签是无法预测的……并且您可能拥有一个Jenkinsfile,该标签会在生产时部署到生产环境标签已建立.

Tags are not built by default (because otherwise you could have a build storm when checking out a repository) and worse, the order tags will be built in is unpredictable... and you might have a Jenkinsfile that deploys to production when a tag is built.

branch-api中有一个名为BranchBuildStrategy的扩展点,如果实现,则可以决定是否构建标签.

There is an extension point in branch-api called BranchBuildStrategy which - if implemented - will allow deciding whether to build tags.

请参见 https://github.com/jenkinsci /github-branch-source-plugin/pull/158#issuecomment-332773194 作为创建此类扩展插件的起点...我相信

See https://github.com/jenkinsci/github-branch-source-plugin/pull/158#issuecomment-332773194 for starting point on how to create such an extension plugin... I believe there is some work on one at https://github.com/AngryBytes/jenkins-build-everything-strategy-plugin

这篇关于Jenkins多分支管道未安排标签作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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