mat*_*sev 13 jenkins jenkinsfile
如果使用特定子目录中的文件更改,我如何才能将Jenkins管道项目的范围限制为仅构建Jenkinsfile?
我有一个包含两个目录的Git存储库.每个目录都包含一个单独的子项目,我想用Jenkins分别构建每个子项目Jenkinsfile.该项目具有以下文件结构:
parent
|
+- subA
| |
| + Jenkinsfile
| + more files related to sub project A
|
+- subB
|
+ Jenkinsfile
+ more files related to sub project B
Run Code Online (Sandbox Code Playgroud)
在Jenkinsfile对subA具有以下配置:
checkout scm: [
$class: 'GitSCM',
branches: [[name: '*/master']],
userRemoteConfigs: [[url: 'https://[path]/parent.git']],
extensions: [[
$class: 'PathRestriction', includedRegions: 'subA/.*'
]]
]
Run Code Online (Sandbox Code Playgroud)
该Jenkinsfile为subB相似,唯一的区别是,它已指定subB为includedRegions.
在Jenkins服务器中,我创建了两个管道项目并Jenkinsfile分别指向它们.如果在文件夹中更改了文件subA,则会触发Jenkins管道项目A,如果在文件夹中更改了文件subB,则会触发Jenkins管道项目B,这是我所期望的.
问题是如果文件被更改,也会触发Jenkins管道项目A subB,反之亦然.
詹金斯版:2.3
注:配置设置Additional Behaviours- > Polling ignores commits in certain paths- > Included Regions于subA/.*或subB/.*分别在老詹金斯(VER 1.649)GUI导致预期的行为.
更新:
添加excludedRegions到Jenkins文件,例如
checkout scm: [
$class: 'GitSCM',
branches: [[name: '*/master']],
userRemoteConfigs: [[url: 'https://[path]/parent.git']],
extensions: [[
$class: 'PathRestriction', excludedRegions: '', includedRegions: 'subA/.*'
]]
]
Run Code Online (Sandbox Code Playgroud)
不会改变行为.尽管只在一个子目录中更改了文件,但两个子项目仍在重建.
| 归档时间: |
|
| 查看次数: |
2668 次 |
| 最近记录: |