Changed default gerrit checkout branch, fixed gating

Change-Id: I1274b72e6d49460ab4317e1305d523834a758cf8
diff --git a/test-groovy-pipeline.groovy b/test-groovy-pipeline.groovy
index acf2a6e..71e9fc0 100644
--- a/test-groovy-pipeline.groovy
+++ b/test-groovy-pipeline.groovy
@@ -9,6 +9,13 @@
 gerrit = new com.mirantis.mk.Gerrit()
 common = new com.mirantis.mk.Common()
 
+def gerritRef
+try {
+  gerritRef = GERRIT_REFSPEC
+} catch (MissingPropertyException e) {
+  gerritRef = null
+}
+
 def defaultGitRef, defaultGitUrl
 try {
     defaultGitRef = DEFAULT_GIT_REF
@@ -28,7 +35,7 @@
               credentialsId : CREDENTIALS_ID
             ])
           } else if(defaultGitRef && defaultGitUrl) {
-              checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "master", CREDENTIALS_ID)
+              checkouted = gerrit.gerritPatchsetCheckout(defaultGitUrl, defaultGitRef, "HEAD", CREDENTIALS_ID)
           }
           if(!checkouted){
             common.errorMsg("Cannot checkout gerrit patchset, GERRIT_REFSPEC and DEFAULT_GIT_REF is null")