我正在通过 Groovy 创建一个多分支管道作业。
multibranchPipelineJob('example') {
branchSources {
github {
id('23232323')
scanCredentialsId('github-ci')
repoOwner('OwnerName')
repository('job-dsl-plugin')
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(10)
}
}
}
答案 0 :(得分:1)
branchSources/github
是静态 API,您不应使用它。 Job DSL 插件的作者停止支持它。更安全的选择是使用动态 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: