Jenkinsfile 中包含的区域的配置? [英] Configuration of includedRegions in Jenkinsfile?

查看:21
本文介绍了Jenkinsfile 中包含的区域的配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 Jenkins 管道项目的范围限制为仅在使用 Jenkinsfile 更改特定子目录中的文件时构建?

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

subAJenkinsfile有如下配置:

checkout scm: [
    $class: 'GitSCM',
    branches: [[name: '*/master']],
    userRemoteConfigs: [[url: 'https://[path]/parent.git']],
    extensions: [[
        $class: 'PathRestriction', includedRegions: 'subA/.*'
    ]]
]

subBJenkinsfile 是类似的,唯一的区别是它指定了subBincludedRegions.

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

注意:配置设置 Additional Behaviours -> Polling ignores commits in certain paths -> Included Regions to subA/.*subB/.* 分别在旧 Jenkins (ver 1.649) GUI 中导致预期的行为.

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 添加到 Jenkinsfiles,例如

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.

推荐答案

目前还不支持 这个问题暗示.

这篇关于Jenkinsfile 中包含的区域的配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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