writeYaml code example
Example: writeYaml
@Grab('org.yaml:snakeyaml:1.17')
import org.yaml.snakeyaml.Yaml
import org.yaml.snakeyaml.DumperOptions
import static org.yaml.snakeyaml.DumperOptions.FlowStyle.BLOCK
node {
def yaml = readYaml file: "test.yml"
yaml.data.info = 'hello world!'
writeFile file:"test.yml", text:yamlToString(yaml)
}
@NonCPS
String yamlToString(Object data){
def opts = new DumperOptions()
opts.setDefaultFlowStyle(BLOCK)
return new Yaml(opts).dump(data)
}