blob: 1466e887507ccf1628819019c2efa4929c23df63 [file] [log] [blame]
Jakub Josefc5a223a2017-03-01 14:40:08 +01001def common = new com.mirantis.mk.Common()
Filip Pytloun38005aa2017-03-06 10:26:38 +01002def git = new com.mirantis.mk.Git()
Jakub Josefc5a223a2017-03-01 14:40:08 +01003stage("Mirror") {
4 node() {
5 try{
6 def branches = BRANCHES.tokenize(',')
7 def pollBranches = []
8 for (i=0; i < branches.size; i++) {
9 pollBranches.add([name:branches[i]])
10 }
11 dir("target") {
12 checkout changelog: true, poll: true,
Jakub Joseffcb615e2017-04-10 14:34:40 +020013 scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
Jakub Josefc5a223a2017-03-01 14:40:08 +010014 extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: TARGET_URL]]]
15 }
16 dir("source") {
17 checkout changelog: true, poll: true,
18 scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
19 extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: SOURCE_URL]]]
Filip Pytloun38005aa2017-03-06 10:26:38 +010020 git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true, true, false)
Jakub Josefc5a223a2017-03-01 14:40:08 +010021 }
22 } catch (Throwable e) {
23 // If there was an error or exception thrown, the build failed
24 currentBuild.result = "FAILURE"
25 throw e
26 } finally {
27 common.sendNotification(currentBuild.result,"",["slack"])
28 }
29 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010030}