Jenkins multibranchPipelineJob作业DSL:如何启用发现分支并抑制SCM自动触发
如何在多分支管道的Jenkins作业DSL中启用行为发现台和属性策略抑制SCM自动触发Jenkins multibranchPipelineJob作业DSL:如何启用发现分支并抑制SCM自动触发,jenkins,jenkins-job-dsl,multibranch-pipeline,Jenkins,Jenkins Job Dsl,Multibranch Pipeline,如何在多分支管道的Jenkins作业DSL中启用行为发现台和属性策略抑制SCM自动触发 可以这样做: multibranchPipelineJob('job name') { branchSources { branchSource { source { git { remote('https://<repo address>.git')
可以这样做:
multibranchPipelineJob('job name') {
branchSources {
branchSource {
source {
git {
remote('https://<repo address>.git')
credentialsId('credential id')
}
}
strategy {
defaultBranchPropertyStrategy {
props {
noTriggerBranchProperty()
}
}
}
}
}
configure {
def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
traits << 'jenkins.plugins.git.traits.BranchDiscoveryTrait' {}
}
triggers {
periodic(2) // Trigger every 2 min.
}
orphanedItemStrategy { discardOldItems { numToKeep(-1) } }
}
multi-branchpipelinejob('job name'){
分支资源{
分支源{
来源{
吉特{
远程('https://.git')
凭证id(“凭证id”)
}
}
策略{
默认分支属性策略{
道具{
noTriggerBranchProperty()
}
}
}
}
}
配置{
def traits=it/sources/data/'jenkins.branch.BranchSource'/source/traits
traits只是为了扩展公认的答案:你不需要那种棘手的traits-Roberto,你能解释一下configure{}子句主体中的闭包吗?例如,“it”和“sources”以及“data”是什么?我试图在多分支管道作业中使用configure{}子句来定义作业的标签(对于所有分支)由于jobdsl当前不支持标签:
multibranchPipelineJob 'job name', {
branchSources {
branchSource {
source {
git {
id 'job name'
remote 'git@<repo-url>.git'
credentialsId 'git-creds-id'
traits {
gitBranchDiscovery()
gitTagDiscovery() // if you need tag discovery
}
}
}
strategy {
defaultBranchPropertyStrategy {
props {
noTriggerBranchProperty()
}
}
}
}
}
}