blob: d1c3ee2ad7787c5c3ecb60002984f36071ae63bb [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()
Jakub Josefa63f9862018-01-11 17:58:38 +010012timeout(time: 12, unit: 'HOURS') {
13 node {
14 try{
15 stage("checkout") {
16 git.checkoutGitRepository('repo', REPO_URL, TARGET_BRANCH, IMAGE_CREDENTIALS_ID)
Jakub Josefb08a94b2017-08-16 13:54:28 +020017 }
Jakub Josefa63f9862018-01-11 17:58:38 +010018 stage("merge") {
19 dir("repo"){
20 sh("git fetch origin/${SOURCE_BRANCH} && git merge ${SOURCE_BRANCH} && git push origin ${TARGET_BRANCH}")
21 }
22 }
23 } catch (Throwable e) {
24 // If there was an error or exception thrown, the build failed
25 currentBuild.result = "FAILURE"
26 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
27 throw e
Jakub Josefb08a94b2017-08-16 13:54:28 +020028 }
Jakub Josefb08a94b2017-08-16 13:54:28 +020029 }
30}
31