Merge "Hide password from cvp-finc tests output"
diff --git a/src/com/mirantis/mcp/Validate.groovy b/src/com/mirantis/mcp/Validate.groovy
index 0b514e5..b1755b2 100644
--- a/src/com/mirantis/mcp/Validate.groovy
+++ b/src/com/mirantis/mcp/Validate.groovy
@@ -295,7 +295,7 @@
}
}
def script = ". ${env.WORKSPACE}/venv/bin/activate; ${settings}" +
- "pytest --junitxml ${output_dir}cvp_sanity.xml --tb=short -sv ${env.WORKSPACE}/cvp-sanity-checks/cvp_checks/tests/${test_set}"
+ "pytest --junitxml ${output_dir}cvp_sanity.xml --tb=short -rs -sv ${env.WORKSPACE}/cvp-sanity-checks/cvp_checks/tests/${test_set}"
withEnv(["SALT_USERNAME=${username}", "SALT_PASSWORD=${password}", "SALT_URL=${salt_url}"]) {
def statusCode = sh script:script, returnStatus:true
}
@@ -366,7 +366,7 @@
}
}
def script = ". ${env.WORKSPACE}/venv/bin/activate; ${settings}" +
- "pytest --junitxml ${output_dir}report.xml --tb=short -sv ${env.WORKSPACE}/${test_set}"
+ "pytest --junitxml ${output_dir}report.xml --tb=short -rs -sv ${env.WORKSPACE}/${test_set}"
withEnv(["SALT_USERNAME=${username}", "SALT_PASSWORD=${password}", "SALT_URL=${salt_url}"]) {
def statusCode = sh script:script, returnStatus:true
}
diff --git a/src/com/mirantis/mk/Gerrit.groovy b/src/com/mirantis/mk/Gerrit.groovy
index b65432d..954600b 100644
--- a/src/com/mirantis/mk/Gerrit.groovy
+++ b/src/com/mirantis/mk/Gerrit.groovy
@@ -383,3 +383,78 @@
}
}
}
+
+/**
+ * Prepare and upload Gerrit commit from prepared repo
+ * @param LinkedHashMap params dict with parameters
+ * venvDir - Absolute path to virtualenv dir
+ * gerritCredentials - credentialsId
+ * gerritHost - gerrit host
+ * gerritPort - gerrit port
+ * repoDir - path to repo dir
+ * repoProject - repo name
+ * repoBranch - repo branch
+ * changeCommitComment - comment for commit message
+ * changeAuthorName - change author
+ * changeAuthorEmail - author email
+ * changeTopic - change topic
+ * gitRemote - git remote
+ * returnChangeInfo - whether to return info about uploaded change
+ *
+ * @return map with change info if returnChangeInfo set to true
+*/
+def prepareGerritAutoCommit(LinkedHashMap params) {
+ def common = new com.mirantis.mk.Common()
+ def git = new com.mirantis.mk.Git()
+ String venvDir = params.get('venvDir')
+ String gerritCredentials = params.get('gerritCredentials')
+ String gerritHost = params.get('gerritHost', 'gerrit.mcp.mirantis.net')
+ String gerritPort = params.get('gerritPort', '29418')
+ String gerritUser = common.getCredentialsById(gerritCredentials, 'sshKey').username
+ String repoDir = params.get('repoDir')
+ String repoProject = params.get('repoProject')
+ String repoBranch = params.get('repoBranch', 'master')
+ String changeCommitComment = params.get('changeCommitComment')
+ String changeAuthorName = params.get('changeAuthorName', 'MCP-CI')
+ String changeAuthorEmail = params.get('changeAuthorEmail', 'mcp-ci-jenkins@ci.mcp.mirantis.net')
+ String changeTopic = params.get('changeTopic', 'auto_ci')
+ Boolean returnChangeInfo = params.get('returnChangeInfo', false)
+ String gitRemote = params.get('gitRemote', '')
+ if (! gitRemote) {
+ dir(repoDir) {
+ gitRemote = sh(
+ script:
+ 'git remote -v | head -n1 | cut -f1',
+ returnStdout: true,
+ ).trim()
+ }
+ }
+ def gerritAuth = ['PORT': gerritPort, 'USER': gerritUser, 'HOST': gerritHost ]
+ def changeParams = ['owner': gerritUser, 'status': 'open', 'project': repoProject, 'branch': repoBranch, 'topic': changeTopic]
+ // find if there is old commit present
+ def gerritChange = findGerritChange(gerritCredentials, gerritAuth, changeParams)
+ def changeId = ''
+ if (gerritChange) {
+ try {
+ def jsonChange = readJSON text: gerritChange
+ changeId = "Change-Id: ${jsonChange['id']}".toString()
+ } catch (Exception error) {
+ common.errorMsg("Can't parse ouput from Gerrit. Check that user ${changeAuthorName} does not have several \
+ open commits to ${repoProject} repo and ${repoBranch} branch with topic ${changeTopic}")
+ throw error
+ }
+ }
+ def commitMessage =
+ """${changeCommitComment}
+
+ |${changeId}
+ """.stripMargin()
+ git.commitGitChanges(repoDir, commitMessage, changeAuthorEmail, changeAuthorName, false)
+ //post change
+ postGerritReview(gerritCredentials, venvDir, repoDir, changeAuthorName, changeAuthorEmail, gitRemote, changeTopic, repoBranch)
+ if (returnChangeInfo) {
+ gerritChange = findGerritChange(gerritCredentials, gerritAuth, changeParams)
+ jsonChange = readJSON text: gerritChange
+ return getGerritChange(gerritUser, gerritHost, jsonChange['number'], gerritCredentials, true)
+ }
+}
diff --git a/src/com/mirantis/mk/Python.groovy b/src/com/mirantis/mk/Python.groovy
index f144a58..d82f68a 100644
--- a/src/com/mirantis/mk/Python.groovy
+++ b/src/com/mirantis/mk/Python.groovy
@@ -34,7 +34,12 @@
sh(returnStdout: true, script: virtualenv_cmd)
if (!offlineDeployment) {
try {
- runVirtualenvCommand(path, "pip install -U setuptools pip")
+ def pipPackage = 'pip'
+ if (python == 'python2') {
+ pipPackage = "\"pip<=19.3.1\""
+ common.infoMsg("Pinning pip package due to end of life of Python2 to ${pipPackage} version.")
+ }
+ runVirtualenvCommand(path, "pip install -U setuptools ${pipPackage}")
} catch (Exception e) {
common.warningMsg("Setuptools and pip cannot be updated, you might be offline but OFFLINE_DEPLOYMENT global property not initialized!")
}
diff --git a/src/com/mirantis/mk/Workflow.groovy b/src/com/mirantis/mk/Workflow.groovy
index 596320b..a3502bd 100644
--- a/src/com/mirantis/mk/Workflow.groovy
+++ b/src/com/mirantis/mk/Workflow.groovy
@@ -55,7 +55,7 @@
global_variables[param.value.get_variable_from_url] = env[param.value.get_variable_from_url] ?: ''
}
if (global_variables[param.value.get_variable_from_url]) {
- variable_content = http.restGet(base, global_variables[param.value.get_variable_from_url])
+ variable_content = http.restGet(base, global_variables[param.value.get_variable_from_url]).trim()
parameters.add([$class: "${param.value.type}", name: "${param.key}", value: variable_content])
println "${param.key}: <${param.value.type}> ${variable_content}"
} else {