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") { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 4 | timeout(time: 12, unit: 'HOURS') { |
| 5 | node() { |
| 6 | try{ |
Martin Polreich | 2c8beed | 2019-03-12 16:44:46 +0100 | [diff] [blame] | 7 | if (BRANCHES.equals("*") || BRANCHES.contains('*')) { |
| 8 | branches = git.getBranchesForGitRepo(SOURCE_URL, BRANCHES) |
| 9 | } else { |
| 10 | branches = BRANCHES.tokenize(',') |
| 11 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 12 | def pollBranches = [] |
Dmitry Burmistrov | 44e2ca2 | 2018-06-29 15:08:57 +0400 | [diff] [blame] | 13 | for (i=0; i < branches.size(); i++) { |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 14 | 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 Josef | c158101 | 2018-01-12 14:36:35 +0100 | [diff] [blame] | 20 | git.mirrorGit(SOURCE_URL, TARGET_URL, CREDENTIALS_ID, BRANCHES, true) |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +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 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 26 | throw e |
| 27 | } finally { |
| 28 | common.sendNotification(currentBuild.result,"",["slack"]) |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 29 | } |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 30 | } |
| 31 | } |
Filip Pytloun | 38005aa | 2017-03-06 10:26:38 +0100 | [diff] [blame] | 32 | } |