multibranchPipelineJob 作业 DSL:如何启用按名称过滤(带通配符)

问题描述 投票:0回答:2

如何在 Jenkins 作业 DSL 中为多分支管道启用按名称过滤(使用通配符)的行为。我尝试了以下方法,但没有成功。

配置{ def Traits = it/sources/data/'jenkins.branch.BranchSource'/source/traits 特征 << 'org.jenkinsci.plugins.github__branch__source.WildcardSCMHeadFilterTrait' { excludes("production") includes("*") } }

jenkins jenkins-job-dsl multibranch-pipeline
2个回答
0
投票
    traits << 'jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait' {
        includes('master PR-*')
    }

帮助我添加行为条目。


0
投票

让我喜欢这个: 示例:

headWildcardFilter {
    excludes('')
    includes('master PR-*')
}

全部_代码:

multibranchPipelineJob('Devops_Testing/hello_world') {
    displayName('try_regular_expression_multi')
    description("""
    hello
    """)
    branchSources {
        branchSource {
            def repo = "https://hello.world.com/"
            source {
                bitbucket {
                    serverUrl('https://hello.world.com/')
                    repoOwner('stackoverflow')
                    id(UUID.nameUUIDFromBytes(repo.getBytes()).toString())
                    repository('hello_world')
                    credentialsId('YOUR_CRED')
                    traits {
                        headWildcardFilter {
                            excludes('')
                            includes('master PR-*')
                        }
                        bitbucketPullRequestDiscovery {
                            strategyId(2)
                        }
                        bitbucketTagDiscovery()
                    }
                }
            }
            buildStrategies {
                buildChangeRequests {
                    ignoreTargetOnlyChanges(true)
                    ignoreUntrustedChanges(true)
                }
                buildTags {
                    atLeastDays('')
                    atMostDays('7')
                }
                buildRegularBranches()
            }
        }
    }
    factory {
        workflowBranchProjectFactory {
            scriptPath('')
        }
    }
    orphanedItemStrategy {
        discardOldItems {
            numToKeep(2)
        }
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.