管道:SCM步骤:签出扩展[排除的区域]

时间:2020-02-07 16:41:43

标签: jenkins-pipeline jenkins-plugins

我在使用Pipeline:SCM步骤Checkout插件中的“排除的区域/包含的区域”时遇到问题。我的管道脚本从多个Repos克隆代码。但是,我不希望所有这些回购中的更改都触发该作业。因此,为了抑制其中一个Repo中的构建形式更改,我尝试使用扩展。但似乎此功能无法正常工作。

我的管道脚本中包含以下代码:

dir ('script') {dir ('script') {
    checkout([
        $class           : 'GitSCM',
        branches         : [[name: '*/master']], 
        extensions       : [
            [$class: 'PathRestriction', excludedRegions: ''], 
            [$class: 'CleanBeforeCheckout'],                          
            [$class: 'DisableRemotePoll']   
        ],
        userRemoteConfigs: [[       
            credentialsId: '12345-xxxxx',
            name         : 'origin',
            refspec      : '+refs/heads/:refs/remotes/origin/+refs/pull/*:refs/remotes/origin/pr/    *',
            url          : 'https://wwwin-github.company.com/myrepo/mycode'
        ]]  
    ])
}```

With the above code, I am under impression that the all changes will be excluded as I kep "excludedRegions" as empty. I have also added '$class:DisableRemotePoll' to see if that works.  None of the above could prevent the build for any changes in the repo.

Could someone pls guide me on how to suppress triggering builds for any repo that I clone in my pipeline script? 



Thanks

-hyvrt

1 个答案:

答案 0 :(得分:0)

不幸的是,詹金斯中的空值都无法按预期工作。 尝试定义

includedRegions

定义您要观看和构建的内容。

表达式会很熟悉

[$class: 'PathRestriction', excludedRegions: '', includedRegions: 'my/source/.*']

请注意,表达式必须像regexp一样,而不是ant表达式