Jenkins 和 Git:监控任何分支上的特定文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29780647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:55:46  来源:igfitidea点击:

Jenkins and Git: Monitor specific folder on any branch

gitgithubjenkins

提问by JaSn

My repo has multiple projects in subfolders with same structure duplicated across multiple branches.

我的 repo 在子文件夹中有多个项目,在多个分支中复制了相同的结构。

I'm trying to set up a job that monitors all branches and triggers a job only when a change in a subdirectory 'Project1' is made. This way I can check if changes to 'Project1' work on release branches and any dev branches people might set up.

我正在尝试设置一个作业来监视所有分支并仅在子目录“Project1”中进行更改时才触发作业。通过这种方式,我可以检查对“Project1”的更改是否适用于发布分支和人们可能设置的任何开发分支。

In theory it seems the Git plugin does let me set this up, by specifying '**' in 'Branches to build' and 'Project1.*' in 'Included Regions'. I also use 'Poll SCM' since that seems to be a prerequisite.

从理论上讲,Git 插件似乎确实让我通过在“要构建的分支”中指定“**”和“包含区域”中的“Project1.*”来进行设置。我也使用“Poll SCM”,因为这似乎是一个先决条件。

This works fine as long as you make changes only to one branch. Once you make a change outside of the 'Project1' folder on another branch, Jenkins picks up a changes from any directory.

只要您只对一个分支进行更改,这种方法就可以正常工作。一旦您在另一个分支上的“Project1”文件夹之外进行更改,Jenkins 就会从任何目录中获取更改。

Is this a bug or am I trying to do something that is not supported?

这是一个错误还是我试图做一些不受支持的事情?

回答by whitediver

It`s possible, but not recommended. You can set additional checkout behavior and then choose which folders should trigger the build and which are not.

可以,但不推荐。您可以设置额外的结帐行为,然后选择哪些文件夹应该触发构建,哪些不是。

enter image description here

在此处输入图片说明

回答by Yuri G.

I think that this answercan help you. You only need to implement the hook with the logic which project to build

我认为这个答案可以帮助你。您只需要使用要构建的项目的逻辑来实现钩子