/**
 * Parent pipeline for running customer's models
 *
 * Params:
 * CUSTOMERS - Comma-separated list of customer's names
 */
def common = new com.mirantis.mk.Common()

timeout(time: 12, unit: 'HOURS') {
  node() {
    try {
      stage("Run customer's salt models tests") {
        if(common.validInputParam("CUSTOMERS")){
           def customerList = CUSTOMERS.tokenize(",").collect{it.trim()}
           for(int i=0; i<customerList.size(); i++){
             def modelName = customerList[i]
             common.infoMsg("Test of ${modelName} starts")
             build job: "test-salt-model-customer-${modelName}"
            // build job: "test-salt-model-customer-${customerList[i]}", parameters: [
            //   [$class: 'StringParameterValue', name: 'DEFAULT_GIT_URL', value: defaultGitUrl],
            //   [$class: 'StringParameterValue', name: 'DEFAULT_GIT_REF', value: defaultGitRef],
            //   [$class: 'StringParameterValue', name: 'CLUSTER_NAME', value: modelName],
            //   [$class: 'StringParameterValue', name: 'NODE_TARGET', value: testTarget],
            //   [$class: 'StringParameterValue', name: 'FORMULAS_SOURCE', value: formulasSource]
            // [$class: 'StringParameterValue', name: 'DISTRIB_REVISION', value: distribRevision],
            //   [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: CREDENTIALS_ID],
            //   [$class: 'StringParameterValue', name: 'SYSTEM_GIT_URL', value: SYSTEM_GIT_URL],
            //   [$class: 'StringParameterValue', name: 'MAX_CPU_PER_JOB', value: MAX_CPU_PER_JOB],
            //   [$class: 'StringParameterValue', name: 'SYSTEM_GIT_REF', value: SYSTEM_GIT_REF],
            //   [$class: 'BooleanParameterValue', name: 'LEGACY_TEST_MODE', value: LEGACY_TEST_MODE.toBoolean()],
            //   [$class: 'BooleanParameterValue', name: 'RECLASS_IGNORE_CLASS_NOTFOUND', value: RECLASS_IGNORE_CLASS_NOTFOUND.toBoolean()]
            // ]
           }
        }
      }
    } catch (Throwable e) {
       // If there was an error or exception thrown, the build failed
       currentBuild.result = "FAILURE"
       currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
       throw e
    } finally {
       common.sendNotification(currentBuild.result, "", ["slack"])
    }
  }
}

