mea*_*our 24 jenkins jenkins-plugins jenkins-job-dsl jenkins-workflow jenkins-pipeline
我安装Pipeline Plugin
了以前调用Workflow Plugin
过的.
https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Plugin
我想知道如何使用Job Dsl创建和配置类型的作业 Pipeline
aga*_*rys 25
你应该用pipelineJob
.
例:
pipelineJob('job-name') {
definition {
cps {
script('logic-here')
sandbox()
}
}
}
Run Code Online (Sandbox Code Playgroud)
J.Z*_*.Z. 23
我相信这个问题是询问如何使用Job DSL创建一个管道作业,该作业引用项目的Jenkins文件,并且不会将作业创建与详细的步骤定义结合起来,如日期答案中给出的那样.这是有道理的:Jenkins作业创建和元数据配置(描述,触发器等)可能属于Jenkins管理员,但开发团队应该控制作业实际执行的操作.
@meallhour,以下是你的追求?(在Job DSL 1.64上工作)
pipelineJob('DSL_Pipeline') {
def repo = 'https://github.com/path/to/your/repo.git'
triggers {
scm('H/5 * * * *')
}
description("Pipeline for $repo")
definition {
cpsScm {
scm {
git {
remote { url(repo) }
branches('master', '**/feature*')
scriptPath('misc/Jenkinsfile.v2')
extensions { } // required as otherwise it may try to tag the repo, which you may not want
}
// the single line below also works, but it
// only covers the 'master' branch and may not give you
// enough control.
// git(repo, 'master', { node -> node / 'extensions' << '' } )
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
参考Job DSL管道工作:https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob,并在http://job-dsl.herokuapp.com/上查看生成的配置.
这个例子对我有用.这是另一个基于对我有用的例子:
pipelineJob('Your App Pipeline') {
def repo = 'https://github.com/user/yourApp.git'
def sshRepo = 'git@git.company.com:user/yourApp.git'
description("Your App Pipeline")
keepDependencies(false)
properties{
githubProjectUrl (repo)
rebuild {
autoRebuild(false)
}
}
definition {
cpsScm {
scm {
git {
remote { url(sshRepo) }
branches('master')
scriptPath('Jenkinsfile')
extensions { } // required as otherwise it may try to tag the repo, which you may not want
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果首先通过UI构建管道,则可以使用config.xml文件和Jenkins文档https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob来创建管道作业.