仅在提交到母版时触发Jenkins Pipeline作业

编程入门 行业动态 更新时间:2024-10-26 10:29:48
本文介绍了仅在提交到母版时触发Jenkins Pipeline作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个由github webhook触发的Jenkins Pipeline作业,因此在对Github的提交中,该构建被触发.但是,我只希望在对master分支进行提交时触发构建.当前,即使在功能分支上进行提交,任何提交都会触发构建.

I have a Jenkins Pipeline job which is triggered of a github webhook, so on a commit to Github the build gets triggered. However, I only want the build to be triggered when a commit is made to the master branch. Currently any commit triggers a build even if the commit is made on a feature branch.

有什么方法可以不借助多分支机构的工作来实现这一目标吗?

Is there any way to achieve this without resorting to a multibranch job?

在Jenkins配置,jenkins文件或Github存储库的webhook中,我看不到任何方法可以过滤分支(用于触发器).

I can't see any way to filter on branch (for the trigger) in the Jenkins config, the jenkinsfile or in the Github repo's webhook.

我可以找到的唯一的分支特定信息是代码将从哪个分支构建,但是对任何其他分支的提交仍将触发"构建.

The only branch specific information I can find is which branch the code will build from but a commit to any other branch will still 'trigger' a build.

任何人都可以帮忙吗?

推荐答案

因此,我对这一点的研究越多,我就越意识到斯蒂芬是对的,我应该使用多分支流水线方法.实际上,在较新的Blue Ocean UI中,默认情况下所有管道都是多分支的,这进一步表明这是可行的方法.

So the more I looked into this, the more i realised that Stephen was right and I should be using the multibranch pipeline approach. Indeed, in the newer Blue Ocean UI, all pipelines are multibranch by default, further suggesting this is the way to go.

关于触发构建的第二个问题,这似乎与已设置的分支源有关.这最初是使用git分支源.一旦将其更改为github分支源,并在jenkins中正确配置了github服务器,则触发器将按预期工作.

As to the second issue around triggering the build, this did seem to be related to the branch source that has been set up. This was originally using the git branch source. Once this was changed to a github branch source and the github server configured correctly in jenkins then the trigger worked as expected.

更多推荐

仅在提交到母版时触发Jenkins Pipeline作业

本文发布于:2023-11-24 05:12:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624078.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   母版   Jenkins   Pipeline

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!