Added git merge branches pipeline + related changes in rollout and test-service pipelines
Change-Id: Id43a3a37da7876c14cfa9ee4fb40320652f74b17
diff --git a/git-merge-branch.groovy b/git-merge-branch.groovy
deleted file mode 100644
index e69de29..0000000
--- a/git-merge-branch.groovy
+++ /dev/null
diff --git a/git-merge-branches-pipeline.groovy b/git-merge-branches-pipeline.groovy
new file mode 100644
index 0000000..cff1db5
--- /dev/null
+++ b/git-merge-branches-pipeline.groovy
@@ -0,0 +1,28 @@
+/**
+ * Git merge branches pipeline
+ * REPO_URL - Repository URL
+ * TARGET_BRANCH - Target branch for merging
+ * SOURCE_BRANCH - The branch will be merged to TARGET_BRANCH
+ * CREDENTIALS_ID - Used credentails ID
+ *
+**/
+
+def common = new com.mirantis.mk.Common()
+def git = new com.mirantis.mk.Git()
+node {
+ try{
+ stage("checkout") {
+ git.checkoutGitRepository('repo', REPO_URL, TARGET_BRANCH, IMAGE_CREDENTIALS_ID)
+ }
+ stage("merge") {
+ dir("repo"){
+ sh("git fetch origin/${SOURCE_BRANCH} && git merge ${SOURCE_BRANCH} && git push origin ${TARGET_BRANCH}")
+ }
+ }
+ } catch (Throwable e) {
+ // If there was an error or exception thrown, the build failed
+ currentBuild.result = "FAILURE"
+ throw e
+ }
+}
+
diff --git a/rollout-config-change.groovy b/rollout-config-change.groovy
index 06219a3..5c83eee 100644
--- a/rollout-config-change.groovy
+++ b/rollout-config-change.groovy
@@ -58,11 +58,11 @@
}
stage('Promote config change in repo') {
- build job: "gerrit-merge-branch", parameters: [
- [$class: 'StringParameterValue', name: 'MODEL_REPO_URL', value: MODEL_REPO_URL],
- [$class: 'StringParameterValue', name: 'MODEL_REPO_CREDENTIALS', value: MODEL_REPO_CREDENTIALS],
- [$class: 'StringParameterValue', name: 'MODEL_REPO_SOURCE_BRANCH', value: MODEL_REPO_SOURCE_BRANCH],
- [$class: 'StringParameterValue', name: 'MODEL_REPO_TARGET_BRANCH', value: MODEL_REPO_TARGET_BRANCH],
+ build job: "git-merge-branches", parameters: [
+ [$class: 'StringParameterValue', name: 'REPO_URL', value: MODEL_REPO_URL],
+ [$class: 'StringParameterValue', name: 'CREDENTIALS_ID', value: MODEL_REPO_CREDENTIALS],
+ [$class: 'StringParameterValue', name: 'SOURCE_BRANCH', value: MODEL_REPO_SOURCE_BRANCH],
+ [$class: 'StringParameterValue', name: 'TARGET_BRANCH', value: MODEL_REPO_TARGET_BRANCH],
]
}
@@ -79,7 +79,7 @@
}
stage('Test config change on prod env') {
- build job: "deploy-test-service", parameters: [
+ def result = build job: "deploy-test-service", parameters: [
[$class: 'StringParameterValue', name: 'SALT_MASTER_URL', value: PRD_SALT_MASTER_URL],
[$class: 'StringParameterValue', name: 'SALT_MASTER_CREDENTIALS', value: PRD_SALT_MASTER_CREDENTIALS],
[$class: 'StringParameterValue', name: 'TEST_SERVICE', value: TEST_SERVICE],
diff --git a/test-service.groovy b/test-service.groovy
index cf1dcc6..29c88b2 100644
--- a/test-service.groovy
+++ b/test-service.groovy
@@ -88,7 +88,18 @@
writeFile(file: 'report.xml', text: salt.getFileContent(saltMaster, TEST_TEMPEST_TARGET, '/root/report.xml'))
junit(keepLongStdio: true, testResults: 'report.xml', healthScaleFactor: Double.parseDouble(TEST_JUNIT_RATIO))
}
-
+ stage("Approve test results"){
+ try {
+ timeout(time: 1, unit: 'HOURS'){
+ userInput = input message: 'Do you want to approve test results?'
+ }
+ common.successMsg("Test results approved")
+ currentBuild.desc = "result: true"
+ } catch(err) { // timeout reached or input false
+ common.errorMsg("Test results not approved")
+ currentBuild.desc = "result: false"
+ }
+ }
} catch (Throwable e) {
currentBuild.result = 'FAILURE'
throw e