Add versions comparison function
PRODX-42360
Change-Id: Ib57d94df3967a5ffba60275a396f881e09b96bb6
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 1507b44..17ab32c 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -8,6 +8,8 @@
import com.cloudbees.groovy.cps.NonCPS
import groovy.json.JsonSlurperClassic
+import java.lang.module.ModuleDescriptor.Version
+
import org.jenkinsci.plugins.workflow.cps.EnvActionImpl
/**
@@ -1194,6 +1196,18 @@
return version ==~ semVerRegex
}
+
+/**
+ * Compare versions. Returns true if ver1 >= ver2, false if ver1 < ver2
+ * @param string ver1
+ * @param string ver2
+ */
+def isVerGreaterOrEqual (String ver1, String ver2) {
+ Version v1 = Version.parse(ver1)
+ Version v2 = Version.parse(ver2)
+ return v1 >= v2
+}
+
def readYaml2(LinkedHashMap kwargs) {
/**
* readYaml wrapper to workaround case when initial file contains