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/gating-pipeline.groovy b/gating-pipeline.groovy
index aeaee9a..15518d4 100644
--- a/gating-pipeline.groovy
+++ b/gating-pipeline.groovy
@@ -4,6 +4,7 @@
* JOBS_NAMESPACE - Gerrit gating jobs namespace (mk, contrail, ...)
*
**/
+import groovy.json.JsonOutput
def common = new com.mirantis.mk.Common()
def gerrit = new com.mirantis.mk.Gerrit()
@@ -18,12 +19,7 @@
}
def callJobWithExtraVars(String jobName) {
- def gerritVars = '\n---'
- for (envVar in env.getEnvironment()) {
- if (envVar.key.startsWith("GERRIT_")) {
- gerritVars += "\n${envVar.key}: '${envVar.value}'"
- }
- }
+ def gerritVars = JsonOutput.toJson(env.getEnvironment().findAll{ it.key.startsWith('GERRIT_') })
testJob = build job: jobName, parameters: [
[$class: 'TextParameterValue', name: 'EXTRA_VARIABLES_YAML', value: gerritVars]
]