Job-dsl-plugin-没有这样的属性:类的可执行文件:java.lang.Thread用于参数化构建测试

时间:2015-10-08 17:06:48

标签: groovy jenkins jenkins-job-dsl

我有一个参数化构建,它在dsl文件中定义为

Thread thr = Thread.currentThread()
def build = thr?.executable
def resolver = build.buildVariableResolver

Map<String, JobParam> paramMap = JobConstants.PARAM_MAP
for (String key : paramMap.keySet()) {
    paramMap.put(key, new JobParam(paramMap.get(key),  (String)resolver.resolve(key)))
}

...

现在我正在尝试测试这个dsl​​文件,并按照测试代码编写

public void testJob() {
    JobManagement jm = new MemoryJobManagement()
    File f = new File("jobs/PipelinesCreator.groovy")
    DslScriptLoader.runDslEngine f.text, jm
}

但是这给了我以下错误:javaposse.jobdsl.dsl.DslScriptException :( script,line 13)没有这样的属性:类的可执行文件:java.lang.Thread

我尝试按照job-dsl-core(https://github.com/jenkinsci/job-dsl-plugin/blob/785de7f877fdbe8fc56b8b2423ae76ec9c59fa66/job-dsl-core/src/test/groovy/javaposse/jobdsl/dsl/DslScriptLoaderSpec.groovy#L238)中的现有测试来运行groovy脚本。

如何解决此问题并使我的测试成功执行。

0 个答案:

没有答案