使用Git排除Jenkins中的区域 [英] Excluded Regions in Jenkins with Git

查看:427
本文介绍了使用Git排除Jenkins中的区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个git仓库,我在Jenkins中创建了两个不同的工作(一个用于生产代码,另一个用于工具)。

我为每个作业添加了Excluded Regions,只在每个正确的文件夹上触发。



我们的git根文件夹包含以下内容:

  / src / 
/ tools /
/测试/
/ doc /
/第三方/

在Jenkins我有以下排除的区域

  / tools /.* 
/ Test Projects /.*
/doc/.*

在我的工具工作中,我有folling Excluded Regions

  / src /.* 
/ Test Projects /.*
/doc/.*

问题是,如果我在文档文件夹中推送更改,则会触发两个作业。我没有任何包含区域。

解决方案

这个设置应该可行。



然而,如果您在Jenkins使用 Gerrit Triggers ,在GitSCM插件中排除/包含区域将不起作用。在Gerrit Trigger插件中,有一个选项可以添加文件路径,它将像包含区域一样工作,也就是说,只有在添加文件路径发生变化时才会触发构建。



在作业的Gerrit触发器配置中添加一个如下所示的文件路径以包含工具目录。



路径工具/ **


I have a git repository where I have created two different jobs in Jenkins (one for production code and one for tools). Where both jobs always are triggered!

I have added Excluded Regions for each jobs to only trigger on each correct folder.

Our git root folder contains the following:

/src/
/tools/
/test/
/doc/
/third party/

In my Source job in Jenkins I have the following Excluded Regions

/tools/.*
/Test Projects/.*
/doc/.*

In my tools job I have the folling Excluded Regions

/src/.*
/Test Projects/.*
/doc/.*

The problem is that if I push a change in doc-folder both jobs are triggered. I don't have any include regions either.

解决方案

This setup should work.

However if you are using Gerrit Triggers in Jenkins the exclude/include regions in GitSCM plugin will not work. In the Gerrit Trigger plugin there is an option to add file paths which will work like an include region, i.e. the build will only get triggered when there is a change in the file path added.

In the Gerrit trigger configuration of your job add a file path like below to include tools directory.

Path tools/**

这篇关于使用Git排除Jenkins中的区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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