我正在使用Job https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob中记录的Job DSL插件创建一个多分支管道作业 创建了多分支管道作业,但是当一个分支具有Jenkins文件时,它不会创建新的管道事件。 每当我触发扫描时,我都会看到以下输出:
Getting remote branches...
Seen branch in repository origin/branch1
Seen branch in repository origin/branch2
Seen branch in repository origin/master
Seen 3 remote branches
Checking branch branch2
‘Jenkinsfile’ not found
Does not meet criteria
Checking branch branch1
‘Jenkinsfile’ found
Met criteria
Done.
[Tue Jun 20 11:52:58 GMT 2017] Finished branch indexing. Indexing took 2.7 sec
Finished: SUCCESS
如果我通过Jenkins UI创建一个多分支管道并运行我看到的工作而不是
multibranchPipelineJob('example') {
branchSources {
git {
remote('https://github.com/jenkinsci/job-dsl-plugin.git')
credentialsId('github-ci')
includes('JENKINS-*')
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(20)
}
}
}
正如您所见,通过Job DSL插件生成作业时,找不到'Jenkinsfile'。我缺少什么?
我的Job DSL插件正在使用示例代码:
ng-href
答案 0 :(得分:1)
该示例将检查的分支限制为以JENKINS-
开头的分支。您的存储库不包含以JENKINS-
开头的任何分支。从Job DSL脚本中删除includes
来电:
multibranchPipelineJob('example') {
branchSources {
git {
remote('https://github.com/jenkinsci/job-dsl-plugin.git')
credentialsId('github-ci')
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(20)
}
}
}