Convert repoDir to absolutePath

Also add getAbsolutePath to mk.Common

Related-Prod: PROD-00000
Change-Id: I64ea1388a02b64675d6b27dbfc6f97e22b7c5f9f
diff --git a/src/com/mirantis/mk/Common.groovy b/src/com/mirantis/mk/Common.groovy
index 401f4f0..031bf6f 100644
--- a/src/com/mirantis/mk/Common.groovy
+++ b/src/com/mirantis/mk/Common.groovy
@@ -40,6 +40,17 @@
 }
 
 /**
+ * Get absolute path via 'realink'
+ *   -m, --canonicalize-missing
+ *     canonicalize by following every symlink in every component of the given name recursively,
+ *     without requirements on components existence
+ */
+def getAbsolutePath(String path) {
+    def absPath = sh script: "readlink -m ${path}", returnStdout: true
+    return absPath.trim()
+}
+
+/**
  * Get UID of jenkins user.
  * Must be run from context of node
  */
diff --git a/src/com/mirantis/mk/ReleaseWorkflow.groovy b/src/com/mirantis/mk/ReleaseWorkflow.groovy
index bfb1155..5858be3 100644
--- a/src/com/mirantis/mk/ReleaseWorkflow.groovy
+++ b/src/com/mirantis/mk/ReleaseWorkflow.groovy
@@ -1,4 +1,5 @@
 package com.mirantis.mk
+
 /**
  * Checkout release metadata repo with clone or without, if cloneRepo parameter is set
  *
@@ -11,13 +12,15 @@
  */
 def checkoutReleaseMetadataRepo(Map params = [:]) {
     def git = new com.mirantis.mk.Git()
+    def common = new com.mirantis.mk.Common()
 
     String gitCredentialsId = params.get('metadataCredentialsId', 'mcp-ci-gerrit')
     String gitUrl           = params.get('metadataGitRepoUrl', "ssh://${gitCredentialsId}@gerrit.mcp.mirantis.net:29418/mcp/artifact-metadata")
     String gitBranch        = params.get('metadataGitRepoBranch', 'master')
     String gitRef           = params.get('metadataGitRepoRef', '')
-    String repoDir          = params.get('repoDir', 'artifact-metadata')
+    String repoDir          = common.getAbsolutePath(params.get('repoDir', 'artifact-metadata'))
     Boolean cloneRepo       = params.get('cloneRepo', true)
+
     if (cloneRepo) {
         stage('Cleanup repo dir') {
             dir(repoDir) {
@@ -42,14 +45,14 @@
  *    - repoDir
  */
 def getReleaseMetadataValue(String key, Map params = [:]) {
+    // Libs
+    def common = new com.mirantis.mk.Common()
+
     String result
     // Get params
     String toxDockerImage   = params.get('toxDockerImage', 'docker-prod-virtual.docker.mirantis.net/mirantis/external/tox')
     String outputFormat     = params.get('outputFormat', 'json')
-    String repoDir          = params.get('repoDir', 'artifact-metadata')
-
-    // Libs
-    def common = new com.mirantis.mk.Common()
+    String repoDir          = common.getAbsolutePath(params.get('repoDir', 'artifact-metadata'))
 
     String opts = ''
     if (outputFormat && !outputFormat.isEmpty()) {
@@ -107,21 +110,21 @@
  */
 
 def updateReleaseMetadata(String key, String value, Map params, Integer dirdepth = 0) {
-    String gitCredentialsId     = params.get('metadataCredentialsId', 'mcp-ci-gerrit')
-    String metadataRepoUrl      = params.get('metadataGitRepoUrl', "ssh://${gitCredentialsId}@gerrit.mcp.mirantis.net:29418/mcp/artifact-metadata")
-    String metadataGerritBranch = params.get('metadataGitRepoBranch', 'master')
-    String toxDockerImage       = params.get('toxDockerImage', 'docker-prod-virtual.docker.mirantis.net/mirantis/external/tox')
-    String repoDir              = params.get('repoDir', 'artifact-metadata')
-    String comment              = params.get('comment', '')
-    String crTopic              = params.get('crTopic', '')
-    String changeAuthorName     = params.get('crAuthorName', 'MCP-CI')
-    String changeAuthorEmail    = params.get('crAuthorEmail', 'mcp-ci-jenkins@ci.mcp.mirantis.net')
-
     def common = new com.mirantis.mk.Common()
     def python = new com.mirantis.mk.Python()
     def gerrit = new com.mirantis.mk.Gerrit()
     def git    = new com.mirantis.mk.Git()
 
+    String gitCredentialsId     = params.get('metadataCredentialsId', 'mcp-ci-gerrit')
+    String metadataRepoUrl      = params.get('metadataGitRepoUrl', "ssh://${gitCredentialsId}@gerrit.mcp.mirantis.net:29418/mcp/artifact-metadata")
+    String metadataGerritBranch = params.get('metadataGitRepoBranch', 'master')
+    String toxDockerImage       = params.get('toxDockerImage', 'docker-prod-virtual.docker.mirantis.net/mirantis/external/tox')
+    String repoDir              = common.getAbsolutePath(params.get('repoDir', 'artifact-metadata'))
+    String comment              = params.get('comment', '')
+    String crTopic              = params.get('crTopic', '')
+    String changeAuthorName     = params.get('crAuthorName', 'MCP-CI')
+    String changeAuthorEmail    = params.get('crAuthorEmail', 'mcp-ci-jenkins@ci.mcp.mirantis.net')
+
     def cred = common.getCredentials(gitCredentialsId, 'key')
     String gerritUser = cred.username
     String gerritHost = metadataRepoUrl.tokenize('@')[-1].tokenize(':')[0]