blob: fa49bbc786ce1e765a9373bbca28f488d2acfb6e [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()
azvyagintsev8710f802019-04-18 19:38:45 +03003
4stage('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 Polreich2c8beed2019-03-12 16:44:46 +010030 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010031 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010032}