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() |
azvyagintsev | 8710f80 | 2019-04-18 19:38:45 +0300 | [diff] [blame] | 3 | |
| 4 | stage('Mirror') { |
| 5 | timeout(time: 12, unit: 'HOURS') { |
| 6 | node() { |
| 7 | try { |
| 8 | if (BRANCHES == '*' || BRANCHES.contains('*')) { |
| 9 | branches = git.getBranchesForGitRepo(SOURCE_URL, BRANCHES) |
| 10 | } else { |
| 11 | branches = BRANCHES.tokenize(',') |
| 12 | } |
| 13 | common.infoMsg('branches to fetch:' + branches.toString()) |
| 14 | def pollBranches = [] |
| 15 | for (i = 0; i < branches.size(); i++) { |
| 16 | pollBranches.add([name: branches[i]]) |
| 17 | } |
| 18 | dir('source') { |
| 19 | checkout changelog: true, poll: true, |
| 20 | scm: [$class : 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false, |
| 21 | extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: SOURCE_URL]]] |
| 22 | git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, branches, true) |
| 23 | } |
| 24 | } catch (Throwable e) { |
| 25 | // If there was an error or exception thrown, the build failed |
| 26 | currentBuild.result = 'FAILURE' |
| 27 | currentBuild.description = currentBuild.description ? e.message + '' + currentBuild.description : e.message |
| 28 | throw e |
| 29 | } |
Martin Polreich | 2c8beed | 2019-03-12 16:44:46 +0100 | [diff] [blame] | 30 | } |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 31 | } |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 32 | } |