Added function for obtaining kitchen suite from env string
Change-Id: I6d48e5fe0ab26958c9d77480fc2af7e8c49a4645
diff --git a/src/com/mirantis/mk/Ruby.groovy b/src/com/mirantis/mk/Ruby.groovy
index 2503292..ca1f567 100644
--- a/src/com/mirantis/mk/Ruby.groovy
+++ b/src/com/mirantis/mk/Ruby.groovy
@@ -64,3 +64,20 @@
return sh(script: "rbenv exec bundler exec kitchen ${cmd}", returnStdout: true)
}
}
+
+/**
+ * Returns suite name from given env
+ * @param kitchenEnv kitchen env string
+ * @return suite name of empty string if no suite found
+ */
+def getSuiteName(kitchenEnv){
+ def suitePattern = java.util.regex.Pattern.compile("\\s?SUITE=([^\\s]*)")
+ def suiteMatcher = suitePattern.matcher(kitchenEnv)
+ if (suiteMatcher.find()) {
+ def suite = suiteMatcher.group(1)
+ if(suite && suite != ""){
+ return suite.replaceAll("_", "-")
+ }
+ }
+ return ""
+}