Refactor collecting YAML with params for child jobs
Jenkins doesn't have shipped groovy/java modules to handle YAML, but JSON
is a subset of YAML.
So let's use standard JSON handling modules to serialize gerrit environment
variables to JSON, and parse it as YAML.
Change-Id: I79a9ba5dd8ec9559581cec3e294b1336ccee85dd
See: https://mirantis.jira.com/browse/PROD-24467
See: https://en.wikipedia.org/wiki/YAML#Comparison_with_JSON
diff --git a/test-system-reclass-pipeline.groovy b/test-system-reclass-pipeline.groovy
index 04eafeb..a8e10b7 100644
--- a/test-system-reclass-pipeline.groovy
+++ b/test-system-reclass-pipeline.groovy
@@ -1,3 +1,5 @@
+import groovy.json.JsonOutput
+
def gerrit = new com.mirantis.mk.Gerrit()
def common = new com.mirantis.mk.Common()
@@ -7,12 +9,7 @@
if (extraVarsYaml != '') {
common.mergeEnv(env, extraVarsYaml)
} else {
- extraVarsYaml = '\n---'
- for (envVar in env.getEnvironment()) {
- if (envVar.key.startsWith("GERRIT_")) {
- extraVarsYaml += "\n${envVar.key}: '${envVar.value}'"
- }
- }
+ extraVarsYaml = JsonOutput.toJson(env.getEnvironment().findAll{ it.key.startsWith('GERRIT_') })
}
def slaveNode = env.SLAVE_NODE ?: 'python&&docker'