问题描述
我正在使用声明性管道语法.我的 jenkins 文件存储在 git hub 存储库中,与要构建的代码分开,因此我设置了 jenkins 作业以从 scm 获取管道脚本,并在 master 分支上选择我的 git 存储库.在我的管道脚本中,我使用 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.
推荐答案
可能的解决方法:
如果 webhook 未在 GitHub 组织级别配置,请为 Jenkinsfile 所在的存储库禁用 webhook
If the webhook is not configured at GitHub org level, disable webhook for the repository where your Jenkinsfile is located
或
在 Jenkins 作业配置中,在 Pipeline > Additional Behaviours > Add 下,选择 Polling ignores commits in certain路径.然后,在 Excluded Regions 文本框中,指定 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 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!