Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 2 | def git = new com.mirantis.mk.Git() |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 3 | stage("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, |
| 13 | scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false, submoduleCfg: [], |
| 14 | 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 Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 20 | git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true, true, false) |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 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 | } finally { |
| 27 | common.sendNotification(currentBuild.result,"",["slack"]) |
| 28 | } |
| 29 | } |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 30 | } |