我正在通过Groovy创建一个多分支管道作业。
multibranchPipelineJob('example') {
branchSources {
github {
id('23232323')
scanCredentialsId('github-ci')
repoOwner('OwnerName')
repository('job-dsl-plugin')
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(10)
}
}
}这很好,但是将发现分支策略设置为所有分支

是否有一种方法可以将同样作为PRs归档的排除分支设置为默认的?

发布于 2021-06-08 12:16:54
branchSources/github是一个静态API,您不应该使用它。Job插件的作者不再支持它。更安全的选择是使用动态API。通过使用以下URL,您可以检查Jenkins上有哪些选项可用:
https://<your-jenkins>/plugin/job-dsl/api-viewer/index.html这是您应该使用的:
multibranchPipelineJob('example') {
branchSources {
source {
github {
id('23232323')
apiUri('apiUrl, example: https://github.com/api/v3')
credentialsId('github-ci')
repoOwner('OwnerName')
repository('job-dsl-plugin')
repositoryUrl('repositoryUrl')
configuredByUrl(false)
traits {
gitHubBranchDiscovery {
strategyId(1)
}
}
}
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(10)
}
}
}战略id:
https://stackoverflow.com/questions/67875764
复制相似问题