Merge "Add support for Openstack Kitchen tests"
diff --git a/test-salt-formulas-env.groovy b/test-salt-formulas-env.groovy
index e2dbf83..608182e 100644
--- a/test-salt-formulas-env.groovy
+++ b/test-salt-formulas-env.groovy
@@ -18,6 +18,7 @@
 }
 
 def checkouted = false
+def openstackTest = false
 
 throttle(['test-formula']) {
   timeout(time: 1, unit: 'HOURS') {
@@ -37,8 +38,16 @@
         }
         stage("kitchen") {
           if (checkouted) {
-            if (fileExists(".kitchen.yml")) {
-              common.infoMsg(".kitchen.yml found, running kitchen tests")
+            if (fileExists(".kitchen.yml") || fileExists(".kitchen.openstack.yml")) {
+              if (fileExists(".kitchen.openstack.yml")) {
+                common.infoMsg("Openstack Kitchen test configuration found, running Openstack kitchen tests.")
+                if (fileExists(".kitchen.yml")) {
+                  common.infoMsg("Ignoring the docker Kitchen test configuration file.")
+                }
+                openstackTest = true
+              } else {
+                common.infoMsg("Docker Kitchen test configuration found, running Docker kitchen tests.")
+              }
               ruby.ensureRubyEnv()
               if (fileExists(".travis.yml")) {
                 common.infoMsg(".travis.yml found, running custom kitchen init")
@@ -46,11 +55,21 @@
                 def kitchenInit = kitchenConfigYML["install"]
                 def kitchenInstalled = false
                 if (kitchenInit && !kitchenInit.isEmpty()) {
-                  for (int i = 0; i < kitchenInit.size(); i++) {
-                    if (kitchenInit[i].trim().startsWith("test -e Gemfile")) { //found Gemfile config
-                      common.infoMsg("Custom Gemfile configuration found, using them")
-                      ruby.installKitchen(kitchenInit[i].trim())
-                      kitchenInstalled = true
+                  if (!openstackTest) {
+                    for (int i = 0; i < kitchenInit.size(); i++) {
+                      if (kitchenInit[i].trim().startsWith("test -e Gemfile")) { //found Gemfile config
+                        common.infoMsg("Custom Gemfile configuration found, using them")
+                        ruby.installKitchen(kitchenInit[i].trim())
+                        kitchenInstalled = true
+                      }
+                    }
+                  } else {
+                    for (int i = 0; i < kitchenInit.size(); i++) {
+                      if (kitchenInit[i].trim().startsWith("git clone")) { //found Gemfile config TODO: Change keywords ??
+                        common.infoMsg("Custom Gemfile configuration found, using them")
+                        sh(kitchenInit[i].trim())
+                        kitchenInstalled = true
+                      }
                     }
                   }
                 }
diff --git a/test-salt-formulas-pipeline.groovy b/test-salt-formulas-pipeline.groovy
index 0caef9c..434654c 100644
--- a/test-salt-formulas-pipeline.groovy
+++ b/test-salt-formulas-pipeline.groovy
@@ -61,6 +61,7 @@
     [$class: 'StringParameterValue', name: 'SALT_VERSION', value: SALT_VERSION]
   ]
 }
+
 timeout(time: 2, unit: 'HOURS') {
   node(slaveNode) {
     try {
@@ -132,8 +133,15 @@
       }
     stage("kitchen") {
         if (checkouted) {
-          if (fileExists(".kitchen.yml")) {
-            common.infoMsg(".kitchen.yml found, running kitchen tests")
+          if (fileExists(".kitchen.yml") || fileExists(".kitchen.openstack.yml")) {
+            if (fileExists(".kitchen.openstack.yml")) {
+              common.infoMsg("Openstack Kitchen test configuration found, running Openstack kitchen tests.")
+              if (fileExists(".kitchen.yml")) {
+                common.infoMsg("Ignoring the docker Kitchen test configuration file.")
+              }
+            } else {
+              common.infoMsg("Docker Kitchen test configuration found, running Docker kitchen tests.")
+            }
             def kitchenEnvs = []
             def filteredEnvs = []
             if (fileExists(".travis.yml")) {