Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 沙箱模式下DSL中的调用路径限制_Git_Jenkins_Jenkins Job Dsl - Fatal编程技术网

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

我的目标是从SCM触发器中排除一些git区域。但我有一些限制

我必须在沙箱模式下运行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插件中未实现路径限制。因此,我不能使用扩展上下文

如果不在沙箱模式下运行,“配置块”将起作用

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('')
                        }
                    }
                }
            }
        }
    }
}