blob: cff1db57c2e09a3d5a0b32aef5fd0861d9d93249 [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"
25 throw e
26 }
27}
28