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