Merge "Fix regex match for child-deploy trigger"
diff --git a/src/com/mirantis/mk/DockerImageScanner.groovy b/src/com/mirantis/mk/DockerImageScanner.groovy
index bb517b1..6920574 100644
--- a/src/com/mirantis/mk/DockerImageScanner.groovy
+++ b/src/com/mirantis/mk/DockerImageScanner.groovy
@@ -143,16 +143,18 @@
 
     def versions = []
     AffectedVersions.each{
-        if (it.containsKey('released') && it['released']) {
-            if (it.containsKey('name') && it['name'].startsWith(filterName)) {
-                if (it.containsKey('releaseDate') && it['releaseDate']) {
-                    versions.add("${it['releaseDate']}`${it['name']}")
-                }
-            }
+        // 'MOSK' doesn not contain 'released' field
+        if (productName != 'mosk' && it.containsKey('released') && it['released']) {
+            return
+        }
+        if (it.containsKey('name') && it['name'].startsWith(filterName)) {
+            def justVersion = it['name'].replaceAll(/.*_/, '')
+            justVersion = justVersion.replaceAll(/([0-9]+\.)([0-9])$/, '$10$2')
+            versions.add("${justVersion}`${it['name']}")
         }
     }
     if (versions) {
-        return versions.sort()[-1].split('`')[-1]
+        return versions.sort()[0].split('`')[-1]
     }
     return defaultJiraAffectedVersion
 }