blob: 63308ee8aa9873284c065034c797b2035b19a644 [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") {
Jakub Josefc2c37172017-06-16 17:53:57 +020012 try{
13 checkout changelog: true, poll: true,
14 scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
15 extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: TARGET_URL]]]
16 } catch(AbortException e){
17 if(e.message.trim().equals("Couldn't find any revision to build. Verify the repository and branch configuration for this job.")){
18 common.warningMsg("Warning: Cannot checkout target repo source repo is empty")
19 } else {
20 throw e
21 }
22 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010023 }
24 dir("source") {
Jakub Josefc2c37172017-06-16 17:53:57 +020025 try{
26 checkout changelog: true, poll: true,
27 scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
28 extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: SOURCE_URL]]]
29 } catch(AbortException e){
30 if(e.message.trim().equals("Couldn't find any revision to build. Verify the repository and branch configuration for this job.")){
31 common.warningMsg("Warning: Cannot checkout source repo source repo is empty")
32 } else {
33 throw e
34 }
35 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010036 git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true, true, false)
Jakub Josefc5a223a2017-03-01 14:40:08 +010037 }
38 } catch (Throwable e) {
39 // If there was an error or exception thrown, the build failed
40 currentBuild.result = "FAILURE"
41 throw e
42 } finally {
43 common.sendNotification(currentBuild.result,"",["slack"])
44 }
45 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010046}