使用基于文件夹中存在的文件或 shell 脚本输出的参数创建 Jenkins 矩阵作业

Create a Jenkins Matrix Job with parameters based on files present in folder or shell script output

我正在尝试根据主机目录中存在的文件在 Jenkins 中创建矩阵配置作业。

有效,如果我们在工作区目录下运行$(ls *.properties)

a.properties
b.properties
c.properties

我想要一个 Matrix 配置作业 运行 使用这 3 个结果作为轴 属性 列表。

我宁愿不使用轻量级上游任务来收集值并为 DynamicAxis 插件填充 属性,但我已经尝试过这个并且无法弄清楚如何获取输出一个 bash 脚本到一个预定义的属性中。在这一点上,我很高兴收到有关如何完成此操作的任何建议。

the groovy axis plugin

This plugin allows to have scriptable axes for Matrix Jobs. Groovy is the scripting language being used.

The script will have to return a list of strings and each of the strings will be an element of the axis.

其中包含您想要的示例

Define an axis whose values are the files in the root directory:

def dir = new File('/')
def result = []
dir.eachFile {
   if (it.isFile()) {
      result += it.canonicalPath
   }
}

return result