答案 0 :(得分:1)
只是为了扩展接受的答案:您不需要那种棘手的 traits << ...
语法来添加分支(或标签)发现。相反,您可以使用 traits { }
部分(请参阅 docs)。
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()
}
}
}
}
}
}
答案 1 :(得分:0)
可以这样做:
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) } }
}