blob: 8766678884aa7b4e5dd17a2fe2f43405303bee88 [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") {
Jakub Josefa63f9862018-01-11 17:58:38 +01004 timeout(time: 12, unit: 'HOURS') {
5 node() {
6 try{
Martin Polreich2c8beed2019-03-12 16:44:46 +01007 if (BRANCHES.equals("*") || BRANCHES.contains('*')) {
8 branches = git.getBranchesForGitRepo(SOURCE_URL, BRANCHES)
9 } else {
10 branches = BRANCHES.tokenize(',')
11 }
Jakub Josefa63f9862018-01-11 17:58:38 +010012 def pollBranches = []
Dmitry Burmistrov44e2ca22018-06-29 15:08:57 +040013 for (i=0; i < branches.size(); i++) {
Jakub Josefa63f9862018-01-11 17:58:38 +010014 pollBranches.add([name:branches[i]])
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]]]
Jakub Josefc1581012018-01-12 14:36:35 +010020 git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true)
Jakub Josefa63f9862018-01-11 17:58:38 +010021 }
22 } catch (Throwable e) {
23 // If there was an error or exception thrown, the build failed
24 currentBuild.result = "FAILURE"
25 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
26 throw e
27 } finally {
28 common.sendNotification(currentBuild.result,"",["slack"])
Jakub Josefc5a223a2017-03-01 14:40:08 +010029 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010030 }
31 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010032}