Fetch specified ref in tag-git-repos.groovy

Change-Id: I03697a026e2874fa7e8b56dbe421579c98db0edb
See: https://mirantis.jira.com/browse/PROD-23781
diff --git a/tag-git-repos.groovy b/tag-git-repos.groovy
index 312ec9e..8e3a918 100644
--- a/tag-git-repos.groovy
+++ b/tag-git-repos.groovy
@@ -16,7 +16,21 @@
 
 def gitRepoAddTag(repoURL, repoName, tag, credentials, ref = "HEAD"){
   common.infoMsg("Tagging: ${repoURL} ${ref} => ${tag}")
-  git.checkoutGitRepository(repoName, repoURL, "master", credentials)
+  checkout([
+    $class: 'GitSCM',
+    branches: [
+      [name: 'FETCH_HEAD'],
+    ],
+    userRemoteConfigs: [
+      [url: repoURL, refspec: ref, credentialsId: credentials],
+    ],
+    extensions: [
+      [$class: 'PruneStaleBranch'],
+      [$class: 'RelativeTargetDirectory', relativeTargetDir: repoName],
+      [$class: 'SubmoduleOption', disableSubmodules: true],
+      [$class: 'UserIdentity', name: 'MCP CI', email: 'ci+infra@mirantis.com'],
+    ],
+  ])
   dir(repoName) {
     sh "git tag -f -a ${tag} ${ref} -m \"Release of mcp version ${tag}\""
     sshagent([credentials]) {