在我的 Jenkinsfile 中,我尝试创建一个简单的 JSON 文件并将其写入工作区文件夹。
JSON文件的内容应该是:
{"people": {"name":"john","surname":"doe"}}
有什么想法吗?
最佳答案
知道了!
script {
def someMap = [
'name' : "john",
'surname' : "doe"
]
def json = new groovy.json.JsonBuilder()
json "people": someMap
def file = new File("$WORKSPACE/people.json")
file.write(groovy.json.JsonOutput.prettyPrint(json.toString()))
}
关于java - Jenkinsfile 写入 JSON 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53079638/