blob: 0d8c47ba8deaefba5b0a6ce87428237a6dc213e8 [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"
Adam Tenglercac28de2017-08-22 15:52:00 +020025 currentBuild.description = e.message
Jakub Josefb08a94b2017-08-16 13:54:28 +020026 throw e
27 }
28}
29