如何在 Jenkins 作业 DSL 中为多分支管道启用按名称过滤(使用通配符)的行为。我尝试了以下方法,但没有成功。
配置{ def Traits = it/sources/data/'jenkins.branch.BranchSource'/source/traits 特征 << 'org.jenkinsci.plugins.github__branch__source.WildcardSCMHeadFilterTrait' { excludes("production") includes("*") } }
traits << 'jenkins.scm.impl.trait.WildcardSCMHeadFilterTrait' {
includes('master PR-*')
}
帮助我添加行为条目。
让我喜欢这个: 示例:
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)
}
}
}