首页 > 解决方案 > 如何在 jenkins 测试工具中使用 getCurrentWorkspace()?

问题描述

在我的 dsl 脚本中,我遍历并读取了一堆文件——这些文件与种子作业在同一个存储库中。

我这样做是为了访问它们(在 jenkins 上工作):

GroovyShell shell = new GroovyShell()
myfiles = hudson.model.Executor.currentExecutor().getCurrentWorkspace().list('/myfolder/**')

如何在测试工具上运行此脚本?

当我通过测试工具运行它时,我得到一个错误。

Cannot invoke method getCurrentWorkspace() on null object

readFileFromWorkspace()from workspace 似乎有效,但我没有看到类似listFilesFromWorkspace. 如何以适用于詹金斯和测试工具的方式获取文件列表?

标签: jenkinsjenkins-groovyjenkins-job-dsl

解决方案


推荐阅读