blob: 8293f87b76cf374b6d09317677106df27f0d72f9 [file] [log] [blame]
Jakub Josefb08a94b2017-08-16 13:54:28 +02001/**
2 * Git merge branches pipeline
3 * REPO_URL - Repository URL
4 * TARGET_BRANCH - Target branch for merging
5 * SOURCE_BRANCH - The branch will be merged to TARGET_BRANCH
6 * CREDENTIALS_ID - Used credentails ID
7 *
8**/
9
10def common = new com.mirantis.mk.Common()
11def git = new com.mirantis.mk.Git()
12node {
13 try{
14 stage("checkout") {
15 git.checkoutGitRepository('repo', REPO_URL, TARGET_BRANCH, IMAGE_CREDENTIALS_ID)
16 }
17 stage("merge") {
18 dir("repo"){
19 sh("git fetch origin/${SOURCE_BRANCH} && git merge ${SOURCE_BRANCH} && git push origin ${TARGET_BRANCH}")
20 }
21 }
22 } catch (Throwable e) {
23 // If there was an error or exception thrown, the build failed
24 currentBuild.result = "FAILURE"
Jakub Josefd2efd7d2017-08-22 17:49:57 +020025 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
Jakub Josefb08a94b2017-08-16 13:54:28 +020026 throw e
27 }
28}
29