[英]Jenkins workflow (pipeline) + JobDSL plugin - SCM does not work
我正在尝试将pipelineJob dsl集成到jenkins DSL中(通过jenkins DSL插件)。
正如詹金斯DSL中的API参考所见,出于我的目的有一个论点。 pipelineJob-> scm-> git
但是在生成之后,UI中根本没有scm视图,我发现如果我制作了纯pipelineJob,那么也就没有scm的UI。
我跟踪了管道插件的源代码,并意识到pipelineJob继承了作业,因此我认为应该有与SCM相关的选项,如普通作业。
有什么方法可以在管道作业中获得正常的scm UI? 还是我只需要通过groovy脚本即可达到目的?
Jenkins作业DSL如下
def projects = [
'Nova',
'Keystone',
'Cinder',
'Glance',
'Horizon',
'Neutron',
'Networking-kakao',
'Neutron-fwaas',
'Neutron-lbaas',
'Octavia',
'Ceilometer',
'Heat',
'Sahara',
'Trove'
]
def codeName = 'mitaka'
def ref = 'kakao/' + codeName
projects.each {
def project = it
def jobName = 'Unit/OpenStack/' + project
project = project.toLowerCase()
pipelineJob(jobName) {
logRotator(daysToKeep = 7, numToKeep = 5)
scm {
concurrentBuild()
git {
remote {
url("https://github.com/openstack/${project}.git")
}
branch("${ref}")
extensions {
wipeOutWorkspace()
}
}
}
definition {
cps {
sandbox()
script("""
node {
stage ('Clone Sources') {
git {
remote {
url("https://github.com/openstack/${project}.git")
credentials("ccc")
}
branch("${ref}")
extensions {
wipeOutWorkspace()
}
}
git {
url 'https://github.com/openstack-tox-base.git'
branch 'rewrite'
}
sh 'cp tox-openstack-base/Dockerfile.test Dockerfile'
}
docker.withServer('tcp://...:2375') {
def img
def base = docker.image('idock.daumkakao.io/openstack/tox/test-base:newton2')
stage ('Build Test Image') {
base.pull()
img = docker.build("tox/newton/test-horizon")
}
stage ('Run Test') {
sh "docker run --rm tox/newton/test-horizon"
}
}
}
""".stripIndent())
}
}
}
}
管道作业不支持scm
块。 不幸的是,Job DSL API允许在pipelineJob
使用scm
块。 这是Job DSL中的未解决问题,请参阅JENKINS-31832 。
要从SCM加载管道脚本,请使用cpsScm
块:
pipelineJob('example') {
definition {
cpsScm {
scm {
git('https://github.com/jenkinsci/job-dsl-plugin.git')
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.