Config File Provider
Plugin不允许您将参数传递给配置文件。您可以使用任何脚本语言来解决您的问题。我最喜欢的方法是使用Groovy插件。选中“执行系统Groovy脚本”复选框,然后粘贴以下脚本:
import groovy.json.*// read build parametersenv = build.getEnvironment(listener)environment = env.get('environment')filename = env.get('filename')// prepare jsondef builder = new JsonBuilder()builder environment: environment, filename: filenamejson = builder.toPrettyString()// print to console and write to a fileprintln jsonnew File(build.workspace.toString() + "\job.json").write(json)输出样本:
{ "environment": "ENV2", "filename": "abc.txt"}


