Merge "[DockerImageScanner] Fix filtering of image key in summary"
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 5027041..448935f 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -3,6 +3,8 @@
import static groovy.json.JsonOutput.prettyPrint
import static groovy.json.JsonOutput.toJson
+import groovy.time.TimeCategory
+
import com.cloudbees.groovy.cps.NonCPS
import groovy.json.JsonSlurperClassic
@@ -25,6 +27,31 @@
}
/**
+ * Return Duration for given datetime period with suffix
+ *
+ * @param input String in format '\d+[smhd]', to convert given number into seconds, minutes, hours
+ * and days duration respectively. For example: '7d' is for 7 days, '10m' - 10 minutes
+ * and so on. Return null if input in incorrect format
+ */
+def getDuration(String input) {
+ // Verify input format
+ if (!input.matches('[0-9]+[smhd]')) {
+ errorMsg("Incorrect input data for getDuration(): ${input}")
+ return
+ }
+ switch (input[-1]) {
+ case 's':
+ return TimeCategory.getSeconds(input[0..-2].toInteger())
+ case 'm':
+ return TimeCategory.getMinutes(input[0..-2].toInteger())
+ case 'h':
+ return TimeCategory.getHours(input[0..-2].toInteger())
+ case 'd':
+ return TimeCategory.getDays(input[0..-2].toInteger())
+ }
+}
+
+/**
* Return workspace.
* Currently implemented by calling pwd so it won't return relevant result in
* dir context
diff --git a/src/com/mirantis/mk/Gerrit.groovy b/src/com/mirantis/mk/Gerrit.groovy
index 88da957..07c6b5d 100644
--- a/src/com/mirantis/mk/Gerrit.groovy
+++ b/src/com/mirantis/mk/Gerrit.groovy
@@ -320,11 +320,13 @@
* HOST, PORT and USER
* @param changeParams Parameters to identify Geriit change e.g.: owner, topic,
* status, branch, project
+ * @param extraFlags Additional flags for gerrit querry for example
+ * '--current-patch-set' or '--comments' as a simple string
*/
-def findGerritChange(credentialsId, LinkedHashMap gerritAuth, LinkedHashMap changeParams) {
+def findGerritChange(credentialsId, LinkedHashMap gerritAuth, LinkedHashMap changeParams, String extraFlags = '') {
scriptText = """
ssh -p ${gerritAuth['PORT']} ${gerritAuth['USER']}@${gerritAuth['HOST']} \
- gerrit query \
+ gerrit query ${extraFlags} \
--format JSON \
"""
changeParams.each {
diff --git a/src/com/mirantis/mk/Ruby.groovy b/src/com/mirantis/mk/Ruby.groovy
index 4681d07..2e1e494 100644
--- a/src/com/mirantis/mk/Ruby.groovy
+++ b/src/com/mirantis/mk/Ruby.groovy
@@ -6,9 +6,9 @@
/**
* Ensures Ruby environment with given version (install it if necessary)
- * @param rubyVersion target ruby version (optional, default 2.2.3)
+ * @param rubyVersion target ruby version (optional, default 2.6.6)
*/
-def ensureRubyEnv(rubyVersion="2.4.1"){
+def ensureRubyEnv(rubyVersion="2.6.6"){
if (!fileExists("/var/lib/jenkins/.rbenv/versions/${rubyVersion}/bin/ruby")){
//XXX: patch ruby-build because debian package is quite old
sh "git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build || git -C ~/.rbenv/plugins/ruby-build pull origin master"