blob: 45536d02b427e045b35e63e38948b11d6fd43ca9 [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{
7 def branches = BRANCHES.tokenize(',')
8 def pollBranches = []
9 for (i=0; i < branches.size; i++) {
10 pollBranches.add([name:branches[i]])
11 }
12 dir("source") {
13 checkout changelog: true, poll: true,
14 scm: [$class: 'GitSCM', branches: pollBranches, doGenerateSubmoduleConfigurations: false,
15 extensions: [[$class: 'CleanCheckout']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: CREDENTIALS_ID, url: SOURCE_URL]]]
Jakub Josefc1581012018-01-12 14:36:35 +010016 git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true)
Jakub Josefa63f9862018-01-11 17:58:38 +010017 }
18 } catch (Throwable e) {
19 // If there was an error or exception thrown, the build failed
20 currentBuild.result = "FAILURE"
21 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
22 throw e
23 } finally {
24 common.sendNotification(currentBuild.result,"",["slack"])
Jakub Josefc5a223a2017-03-01 14:40:08 +010025 }
Jakub Josefc5a223a2017-03-01 14:40:08 +010026 }
27 }
Filip Pytloun38005aa2017-03-06 10:26:38 +010028}