Merge "force the inclusion of the original source"
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 768e180..c356da8 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -370,3 +370,25 @@
       common.errorMsg("Failed to execute cmd: ${cmd}\n output: ${output}")
     }
 }
+
+/**
+ * Check variable contains keyword
+ * @param variable keywork is searched (contains) here
+ * @param keyword string to look for
+ * @return True if variable contains keyword (case insensitive), False if do not contains or any of input isn't a string
+ */
+
+def checkContains(variable, keyword) {
+    if (binding.variables.containsKey(variable)) {
+        v = binding.variables[variable]
+
+        if (v instanceof String && keyword instanceof String) {
+            return v.toLowerCase().contains(keyword.toLowerCase())
+        } else {
+            return False
+        }
+
+    } else {
+        return False
+    }
+}
diff --git a/src/com/mirantis/mk/Gerrit.groovy b/src/com/mirantis/mk/Gerrit.groovy
index 81e165b..dc3de1b 100644
--- a/src/com/mirantis/mk/Gerrit.groovy
+++ b/src/com/mirantis/mk/Gerrit.groovy
@@ -31,6 +31,12 @@
     def merge = config.get('withMerge', false)
     def wipe = config.get('withWipeOut', false)
     def credentials = config.get('credentialsId','')
+    def gerritRefSpec = config.get('gerritRefSpec', GERRIT_REFSPEC)
+    def gerritName = config.get('gerritName', GERRIT_NAME)
+    def gerritHost = config.get('gerritHost', GERRIT_HOST)
+    def gerritPort = config.get('gerritPort', GERRIT_PORT)
+    def gerritProject = config.get('gerritProject', GERRIT_PROJECT)
+    def gerritBranch = config.get('gerritBranch', GERRIT_BRANCH)
 
     // default parameters
     def scmExtensions = [
@@ -39,21 +45,21 @@
     ]
     def scmUserRemoteConfigs = [
         name: 'gerrit',
-        refspec: "${GERRIT_REFSPEC}"
+        refspec: gerritRefSpec
     ]
 
     if (credentials == '') {
         // then try to checkout in anonymous mode
-        scmUserRemoteConfigs.put('url',"https://${GERRIT_HOST}/${GERRIT_PROJECT}")
+        scmUserRemoteConfigs.put('url',"https://${gerritHost}/${gerritProject}")
     } else {
         // else use ssh checkout
-        scmUserRemoteConfigs.put('url',"ssh://${GERRIT_NAME}@${GERRIT_HOST}:${GERRIT_PORT}/${GERRIT_PROJECT}.git")
+        scmUserRemoteConfigs.put('url',"ssh://${gerritName}@${gerritHost}:${gerritPort}/${gerritProject}.git")
         scmUserRemoteConfigs.put('credentialsId',credentials)
     }
 
     // if we need to "merge" code from patchset to GERRIT_BRANCH branch
     if (merge) {
-        scmExtensions.add([$class: 'LocalBranch', localBranch: "${GERRIT_BRANCH}"])
+        scmExtensions.add([$class: 'LocalBranch', localBranch: "${gerritBranch}"])
     }
     // we need wipe workspace before checkout
     if (wipe) {
@@ -63,7 +69,7 @@
     checkout(
         scm: [
             $class: 'GitSCM',
-            branches: [[name: "${GERRIT_BRANCH}"]],
+            branches: [[name: "${gerritBranch}"]],
             extensions: scmExtensions,
             userRemoteConfigs: [scmUserRemoteConfigs]
         ]
diff --git a/src/com/mirantis/mk/Ssh.groovy b/src/com/mirantis/mk/Ssh.groovy
index 4526d6d..4969da3 100644
--- a/src/com/mirantis/mk/Ssh.groovy
+++ b/src/com/mirantis/mk/Ssh.groovy
@@ -26,6 +26,10 @@
         host = result.group(1)
         port = 22
     } else {
+        // test for protocol
+        if(url.indexOf("://") == -1){
+            url="ssh://" + url
+        }
         parsed = new URI(url)
         host = parsed.host
         port = parsed.port && parsed.port > 0 ? parsed.port: 22