简体   繁体   English

在 Jenkins 中使用 pollSCM 和 Scan Multibranch Pipeline Triggers 有什么区别?

[英]What is the difference between using the pollSCM and the Scan Multibranch Pipeline Triggers in Jenkins?

I've been using Jenkins and I've seen a lot of Pipeline examples (declarative ones) and I've seen some using the pollSCM property in the Jenkinsfile to trigger a build, like this:我一直在使用 Jenkins,并且我看到了很多 Pipeline 示例(声明式示例),并且我看到了一些使用pollSCM中的Jenkinsfile属性来触发构建,如下所示:

triggers {
        pollSCM('H/5 * * * *')
}

However, I've seen this Scan Multibranch Pipeline Triggers option when configuring a Multibranch pipeline.但是,我在配置多分支管道时看到了这个扫描多分支管道触发器选项。 I'm not sure what's the difference between those.我不确定它们之间有什么区别。

All this problem came to me because I'm facing some cases where two builds are being triggered for the same job, and I thought it was because I have both these options configured.所有这些问题都出现在我身上,因为我面临着为同一作业触发两个构建的某些情况,我认为这是因为我配置了这两个选项。

Can anyone please help me understand this difference?任何人都可以帮助我理解这种差异吗?

Thank you!谢谢!

The 'Scan Multibranch Pipeline' trigger will scan the repository for new branches and changes in existing branches. “扫描多分支管道”触发器将扫描存储库中的新分支和现有分支中的更改。 By default it will trigger a new build for all branches which have been updated.默认情况下,它将为所有已更新的分支触发新构建。 However in the multibranch job configuration you can disable this automatic trigger for specific - or all - branches.但是,在多分支作业配置中,您可以为特定或所有分支禁用此自动触发器。

The 'Poll SCM' option is branch-specific. 'Poll SCM' 选项是特定于分支的。 Within a Jenkinsfile you may configure different options for different branches.在 Jenkinsfile 中,您可以为不同的分支配置不同的选项。 This option will never be able to trigger the very first build for a branch as it would need at least one build so the properties step gets executed and the 'poll SCM' option set.此选项永远无法触发分支的第一个构建,因为它至少需要一个构建,以便执行properties步骤并设置“轮询 SCM”选项。 That is: Any change here will only get effective AFTER the next build.也就是说:这里的任何更改只会在下一次构建后生效。

Therefore I'd recommend to stick to the trigger based on the Multibranch branch scan - if possible.因此,如果可能的话,我建议坚持基于 Multibranch 分支扫描的触发器。 However in some special cases (eg first build on a new branch never be built automatically) it still might be useful to use the poll SCM feature.然而,在某些特殊情况下(例如第一次在新分支上构建永远不会自动构建),使用 poll SCM 功能仍然可能有用。 In that case you might want to disable the automatic trigger as required.在这种情况下,您可能希望根据需要禁用自动触发器。

Last but not least the poll SCM feature sometimes uses a different plugin than the Scan Multibranch Pipeline, eg for Bitbucket.最后但并非最不重要的一点是,轮询 SCM 功能有时会使用与 Scan Multibranch Pipeline 不同的插件,例如 Bitbucket。 AFAIK for Bitbucket the multibranch trigger is little bit more flexible, allows to trigger a build on more events compared the the plain Bitbucket trigger. AFAIK for Bitbucket 多分支触发器更灵活一点,与普通的 Bitbucket 触发器相比,允许在更多事件上触发构建。

I think pollSCM must be the jenkins plugin我认为 pollSCM 必须是 jenkins 插件

https://wiki.jenkins.io/display/JENKINS/PollSCM+Plugin https://wiki.jenkins.io/display/JENKINS/PollSCM+Plugin

Multibranch pipeline : This is the type of pipeline, where jenkins scan and pull from all the branch within the repository , so the build will trigger automatically when some code is checked in within the branch (if you have configured it)多分支管道:这是管道的类型,jenkins 扫描并从存储库中的所有分支中拉取,因此在分支内检入某些代码时会自动触发构建(如果您已配置它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM