如何从jenkins作业的scm轮询中排除jenkins文件 [英] How to exclude jenkins files from scm polling on a jenkins job

查看:146
本文介绍了如何从jenkins作业的scm轮询中排除jenkins文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用声明式管道语法.我的jenkins文件存储在git中心存储库中,与要构建的代码分开,因此我设置了jenkins作业以从scm获取管道脚本,并在master分支上选择了git repo. 在我的管道脚本中,我正在使用checkout步骤从另一个源(在我的情况下为RTC存储库,但我想另一个git存储库将是相同的场景)中获取真实代码. 一切正常,如果我通过轮询scm来触发构建,则如果两个存储库中的任何一个发生更改(我会说是按设计),它将开始.

I'm working with declarative pipeline syntax. My jenkins files are stored on a git hub repository, separated from the code to build, so I set up the jenkins job to get the pipeline script from scm, selecting my git repo on master branch. Within my pipeline script I'm using the checkout step to get my real code from another source (an RTC repository in my case, but I suppose another git repository would be the same scenario). Everything works well and if I enable to trigger the build by polling scm it will start if there are changes in any of the two repository (by design I would say).

我的问题是,如果更改发生在jenkins文件存储库中,但仅当更改发生在包含实际代码的存储库中时,我想避免触发构建.在检出步骤中,这很容易,因为可以启用/禁用单个轮询,但是在作业本身中,我找不到任何方法来跳过对jenkins文件存储库的轮询.

My problem is that I would like to avoid to trigger the build if the change happened in the jenkins files repository, but only when it happens in the repository that contain the actual code. In the check-out step it would be easy as there is an option to enable/disable the single poll, but in the job itself I can't find any way to skip polling for the jenkins file repository.

我尝试了其他行为不要在提交通知上触发构建",但它似乎没有效果,至少没有以我想要的方式实现.

I tried the additional behavior "Don't trigger a build on commit notification" but it does not seems to have effect, at least not in the way I would like.

推荐答案

可能的解决方法:

  • 如果未在GitHub组织级别配置webhook,请为您的Jenkinsfile所在的存储库禁用webhook

  • If the webhook is not configured at GitHub org level, disable webhook for the repository where your Jenkinsfile is located

OR

在Jenkins作业配置中的管道> 其他行为> 添加下,选择轮询会忽略某些提交路径.然后,在排除的区域文本框中,指定Jenkinsfile路径或.* 以排除所有内容.

In the Jenkins job configuration, under Pipeline > Additional Behaviours > Add, select Polling ignores commits in certain paths. Then, in the Excluded Regions textbox, specify the Jenkinsfile path or .* to exclude everything.

这篇关于如何从jenkins作业的scm轮询中排除jenkins文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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