Make correct render when dump Map object to YAML
Add correct YAML block ctructure when dump Map object to YAML
Before:
`parameters:
_param: {cookiecutter_template_branch: release/proposed/2019.2.0,
shared_reclass_branch: release/proposed/2019.2.0,
apt_mk_version: "testing"}
`
After:
`parameters:
_param:
cookiecutter_template_branch: release/proposed/2019.2.0
shared_reclass_branch: release/proposed/2019.2.0
apt_mk_version: testing
`
Change-Id: Ifda304ba85369b25f5edcfdbdd479c7fdcf15c55
Related-Prod: PROD-30708
diff --git a/src/com/mirantis/mcp/Common.groovy b/src/com/mirantis/mcp/Common.groovy
index df3ef30..b83a714 100644
--- a/src/com/mirantis/mcp/Common.groovy
+++ b/src/com/mirantis/mcp/Common.groovy
@@ -1,10 +1,12 @@
package com.mirantis.mcp
+import static org.yaml.snakeyaml.DumperOptions.FlowStyle.BLOCK
import java.util.zip.GZIPInputStream
import java.util.zip.GZIPOutputStream
@Grab(group='org.yaml', module='snakeyaml', version='1.17')
import org.yaml.snakeyaml.Yaml
+import org.yaml.snakeyaml.DumperOptions
/**
* https://issues.jenkins-ci.org/browse/JENKINS-26481
@@ -53,7 +55,10 @@
*/
@NonCPS
def dumpYAML(Map map) {
- def yaml = new Yaml()
+ DumperOptions options = new DumperOptions()
+ options.setPrettyFlow(true)
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK)
+ def yaml = new Yaml(options)
return yaml.dump(map)
}