Jenkins Groovy - using modified data from readYaml to write back into yml file

Viewed 24883

I am using Jenkins readYaml to read the data as follows:

data = readYaml file: "test.yml"
//modify
data.info = "b"

I want to write this modified data back to test.yml in Jenkins. How can this be achieved?

2 Answers

There is a writeYaml nowadays, see pipeline-utility-steps-plugin

mydata = readYaml file: "test.yml"

// modify
mydata.info = "b"
writeYaml file: 'newtest.yaml', data: mydata
Related