I have a yaml file on a Jenkins pipeline (scripted in Groovy) and I want to convert that yaml file to JSON format to be parsed in that format.
I defined a variable (data) that will contain all the yaml file content. Don't know if that makes it easier to convert or not, but otherwise I can just convert the yaml file without putting the content on a variable.
Groovy stage script:
stage ("GET deployConfig file"){
def data = readYaml file: './evaluations/integration-test-
docker/dev/deployConfig.yaml'
println("YAML-FILE: " + data)
}
Does anyone know how can achieve that?
thanks
Convert to json and write it to file
import groovy.json.*
stage{
def data = readYaml file: ....
def json = new JsonBuilder(data).toPrettyString()
writeFile file: ..., text: json
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.