Git 沙箱模式下DSL中的调用路径限制
我的目标是从SCM触发器中排除一些git区域。但我有一些限制 我必须在沙箱模式下运行DSL作业Git 沙箱模式下DSL中的调用路径限制,git,jenkins,jenkins-job-dsl,Git,Jenkins,Jenkins Job Dsl,我的目标是从SCM触发器中排除一些git区域。但我有一些限制 我必须在沙箱模式下运行DSL作业 pipelineJob("jobname") { //.. definition { cpsScm { scm { git { //.. extensions { relativeTargetDi
pipelineJob("jobname") {
//..
definition {
cpsScm {
scm {
git {
//..
extensions {
relativeTargetDirectory("myRootPath") // works because implemented [in DSL plugin][2]
pathRestriction('includedPaths', 'excludedPaths') // not implemented in dsl plugin
}
// code below doesn't allowed in sandbox mode
configure { node ->
node / 'extensions' / 'hudson.plugins.git.extensions.impl.PathRestriction' {
excludedRegions 'excludedPaths'
}
}
}
}
}
}
}
解决了我的问题。但我找不到在沙盒模式下调用它的方法
DSL插件中未实现路径限制。因此,我不能使用扩展上下文
如果不在沙箱模式下运行,“配置块”将起作用
pipelineJob("jobname") {
//..
definition {
cpsScm {
scm {
git {
//..
extensions {
relativeTargetDirectory("myRootPath") // works because implemented [in DSL plugin][2]
pathRestriction('includedPaths', 'excludedPaths') // not implemented in dsl plugin
}
// code below doesn't allowed in sandbox mode
configure { node ->
node / 'extensions' / 'hudson.plugins.git.extensions.impl.PathRestriction' {
excludedRegions 'excludedPaths'
}
}
}
}
}
}
}
在将“路径限制”添加到作业DSL之前,我需要一个变通方法
我还创建了对作业DSL插件的路径限制,
诸如此类:
pipelineJob(jobName) {
concurrentBuild(true)
logRotator {
numToKeep(5)
}
description("description")
triggers {
scm('H/3 * * * *')
}
definition {
cpsScm {
lightweight(true)
scm {
git{
branch("master")
remote {
credentials(credID)
url(gitUrl)
scriptPath(scriptName)
}
configure {
it / extensions / "hudson.plugins.git.extensions.impl.PathRestriction" {
includedRegions("JenkinsFiles/JobDSL/.*\\.groovy")
excludedRegions('')
}
}
}
}
}
}
}