在Jenkinsfile中配置includedRegions? [英] Configuration of includedRegions in Jenkinsfile?
问题描述
如何仅使用Jenkinsfile
更改特定子目录中的文件,才能将Jenkins管道项目的范围限制为仅构建?
How can I limit the scope of a Jenkins pipeline project to only be built if a file in specific subdirectory is changed using Jenkinsfile
?
我有一个带有两个目录的Git存储库.每个目录包含一个单独的子项目,我想由Jenkins使用Jenkinsfile
分别构建每个子项目.该项目具有以下文件结构:
I have a single Git repository with two directories. Each directory contains a separate subproject and I would like to build each subproject separately by Jenkins using Jenkinsfile
. The project has the following file structure:
parent
|
+- subA
| |
| + Jenkinsfile
| + more files related to sub project A
|
+- subB
|
+ Jenkinsfile
+ more files related to sub project B
subA
的Jenkinsfile
具有以下配置:
checkout scm: [
$class: 'GitSCM',
branches: [[name: '*/master']],
userRemoteConfigs: [[url: 'https://[path]/parent.git']],
extensions: [[
$class: 'PathRestriction', includedRegions: 'subA/.*'
]]
]
subB
的Jenkinsfile
与之类似,唯一的区别在于它已将subB
指定为includedRegions
.
The Jenkinsfile
for subB
is similar, the only difference being that it has specified subB
as includedRegions
.
在Jenkins服务器中,我创建了两个管道项目并将它们分别指向每个Jenkinsfile
.如果更改了文件夹subA
中的文件,则会触发Jenkins管道项目A;如果更改了文件夹subB
中的文件,则会触发Jenkins管道项目B,这就是我的期望.
In the Jenkins server, I have created two pipeline projects and pointed them to each Jenkinsfile
respectively. If a file is changed in the folder subA
, Jenkins pipeline project A is triggered and if a file is changed in folder subB
, Jenkins pipeline project B is triggered, which is what I expect.
问题在于,如果在subB
中更改了文件,也会触发Jenkins管道项目A,反之亦然.
The problem is that the Jenkins pipeline project A is also triggered if a file is changed in subB
and vice versa.
Jenkins版本:2.3
Jenkins version: 2.3
注意:
在旧的Jenkins(版本1.649)GUI中分别将设置Additional Behaviours
-> Polling ignores commits in certain paths
-> Included Regions
设置为subA/.*
或subB/.*
会导致预期的行为.
Note:
Configuring the setting Additional Behaviours
-> Polling ignores commits in certain paths
-> Included Regions
to subA/.*
or subB/.*
respectively in the old Jenkins (ver 1.649) GUI results in the expected behavior.
更新:
将excludedRegions
添加到Jenkins文件中,例如
Adding excludedRegions
to the Jenkinsfiles, e.g.
checkout scm: [
$class: 'GitSCM',
branches: [[name: '*/master']],
userRemoteConfigs: [[url: 'https://[path]/parent.git']],
extensions: [[
$class: 'PathRestriction', excludedRegions: '', includedRegions: 'subA/.*'
]]
]
不会更改行为.尽管仅在一个子目录中更改了文件,但两个子项目仍在重建.
does not change the behavior. Both subprojects are still rebuilt, despite files are only changed in one subdirectory.
推荐答案
由于 查看全文