Make gerrit refspec optional

Change-Id: I09b5d7a2e7831051d9dac544664248895194ef4a
diff --git a/src/com/mirantis/mk/Gerrit.groovy b/src/com/mirantis/mk/Gerrit.groovy
index 0ddc4e8..c731df3 100644
--- a/src/com/mirantis/mk/Gerrit.groovy
+++ b/src/com/mirantis/mk/Gerrit.groovy
@@ -54,8 +54,10 @@
         ]
         def scmUserRemoteConfigs = [
             name: 'gerrit',
-            refspec: gerritRefSpec
         ]
+        if(gerritRefSpec && gerritRefSpec != ""){
+            scmUserRemoteConfigs.put('refspec', gerritRefSpec)
+        }
 
         if (credentials == '') {
             // then try to checkout in anonymous mode
@@ -98,10 +100,9 @@
         }
         return true
     }else{
-        def common = new com.mirantis.mk.Common()
-        common.errorMsg("Cannot perform gerrit checkout, given config file is not valid")
-        return false
+        throw new Exception("Cannot perform gerrit checkout, given config file is not valid")
     }
+    return false
 }
 /**
  * Execute git clone and checkout stage from gerrit review
@@ -147,6 +148,5 @@
            config.get("gerritHost","") != null && config.get("gerritHost","") != "" &&
            config.get("gerritPort","") != null && config.get("gerritPort","") != "" &&
            config.get("gerritProject","") != null && config.get("gerritProject","") != "" &&
-           config.get("gerritBranch","") != null && config.get("gerritBranch","") != "" &&
-           config.get("gerritRefSpec","") != null && config.get("gerritRefSpec","") != ""
+           config.get("gerritBranch","") != null && config.get("gerritBranch","") != ""
 }
\ No newline at end of file