Add 'use_template' option for job parameters in Workflow.groovy

- Add "use_template" option to assemble different artifact paths
  into a single job parameter, for example:

    REPORTS_LIST:
      type: TextParameterValue
      use_template: |
        REPORT_SI_KAAS_BOOTSTRAP: \$REPORT_SI_KAAS_BOOTSTRAP
        REPORT_SI_KAAS_UI: \$REPORT_SI_KAAS_UI
        REPORT_KAAS_UI: \$REPORT_KAAS_UI

https://mirantis.jira.com/browse/PROD-33442

Change-Id: I069b6902336ec1c530bb436efc72ca570914f23e
diff --git a/src/com/mirantis/mk/Workflow.groovy b/src/com/mirantis/mk/Workflow.groovy
index 25191b7..5e99c67 100644
--- a/src/com/mirantis/mk/Workflow.groovy
+++ b/src/com/mirantis/mk/Workflow.groovy
@@ -23,6 +23,8 @@
  * @param job_name          Name of the running job
  * @param job_parameters    Map that declares which values from global_variables should be used, in the following format:
  *                          {'PARAM_NAME': {'type': <job parameter $class name>, 'use_variable': <a key from global_variables>}, ...}
+ *                          or
+ *                          {'PARAM_NAME': {'type': <job parameter $class name>, 'use_template': <a GString multiline template with variables from global_variables>}, ...}
  * @param global_variables  Map that keeps the artifact URLs and used 'env' objects:
  *                          {'PARAM1_NAME': <param1 value>, 'PARAM2_NAME': 'http://.../artifacts/param2_value', ...}
  * @param propagate         Boolean. If false: allows to collect artifacts after job is finished, even with FAILURE status
@@ -31,14 +33,22 @@
  */
 def runJob(job_name, job_parameters, global_variables, Boolean propagate = false) {
     def parameters = []
+    def engine = new groovy.text.GStringTemplateEngine()
+    def template
 
     // Collect required parameters from 'global_variables' or 'env'
     for (param in job_parameters) {
-        if (!global_variables[param.value.use_variable]) {
-            global_variables[param.value.use_variable] = env[param.value.use_variable] ?: ''
+        if (param.value.containsKey('use_variable')) {
+            if (!global_variables[param.value.use_variable]) {
+                global_variables[param.value.use_variable] = env[param.value.use_variable] ?: ''
+            }
+            parameters.add([$class: "${param.value.type}", name: "${param.key}", value: global_variables[param.value.use_variable]])
+            println "${param.key}: <${param.value.type}> ${global_variables[param.value.use_variable]}"
+        } else if (param.value.containsKey('use_template')) {
+            template = engine.createTemplate(param.value.use_template).make(global_variables)
+            parameters.add([$class: "${param.value.type}", name: "${param.key}", value: template.toString()])
+            println "${param.key}: <${param.value.type}>\n${template.toString()}"
         }
-        parameters.add([$class: "${param.value.type}", name: "${param.key}", value: global_variables[param.value.use_variable]])
-        println "${param.key}: <${param.value.type}> ${global_variables[param.value.use_variable]}"
     }
 
     // Build the job
@@ -164,9 +174,13 @@
  *     - job: testrail-report
  *       ignore_failed: true
  *       parameters:
- *         REPORT_SI_KAAS_UI_URL:
+ *         KAAS_VERSION:
  *           type: StringParameterValue
- *           use_variable: REPORT_SI_KAAS_UI
+ *           use_variable: KAAS_VERSION
+ *         REPORTS_LIST:
+ *           type: TextParameterValue
+ *           use_template: |
+ *             REPORT_SI_KAAS_UI: \$REPORT_SI_KAAS_UI
  *     """
  *
  *     runScenario(scenario)