Kirill Mashchenko | da53589 | 2018-09-05 11:05:52 +0300 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
Ivan Udovichenko | 26208ed | 2020-10-29 16:59:09 +0300 | [diff] [blame^] | 2 | def s4cmdOpts = ' --sync-check ' |
| 3 | Boolean forceUpload = (env.FORCE_UPLOAD ?: false).toBoolean() |
Kirill Mashchenko | da53589 | 2018-09-05 11:05:52 +0300 | [diff] [blame] | 4 | |
| 5 | node("docker") { |
| 6 | stage('Prepare') { |
| 7 | img = docker.image(IMAGE) |
| 8 | img.pull() |
| 9 | } |
| 10 | stage('Upload') { |
Ivan Udovichenko | 26208ed | 2020-10-29 16:59:09 +0300 | [diff] [blame^] | 11 | FILENAMES.split().each { filenamePath -> |
| 12 | url = "${SOURCE}/${filenamePath}" |
| 13 | filename = filenamePath.tokenize('/')[-1] |
azvyagintsev | ac363ef | 2018-11-23 20:13:08 +0200 | [diff] [blame] | 14 | opts = s4cmdOpts |
Ivan Udovichenko | 26208ed | 2020-10-29 16:59:09 +0300 | [diff] [blame^] | 15 | if(filenamePath.contains('stable') || forceUpload) { |
| 16 | common.warningMsg("Going to ovveride ${filenamePath}") |
azvyagintsev | ac363ef | 2018-11-23 20:13:08 +0200 | [diff] [blame] | 17 | opts = opts + '--force' |
| 18 | } |
Kirill Mashchenko | da53589 | 2018-09-05 11:05:52 +0300 | [diff] [blame] | 19 | img.withRun("--entrypoint='/bin/bash'") { c -> |
Ivan Udovichenko | 26208ed | 2020-10-29 16:59:09 +0300 | [diff] [blame^] | 20 | withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'aws-s3', |
Kirill Mashchenko | da53589 | 2018-09-05 11:05:52 +0300 | [diff] [blame] | 21 | usernameVariable: 'S3_ACCESS_KEY', passwordVariable: 'S3_SECRET_KEY']]) { |
| 22 | img.inside("-e S3_ACCESS_KEY=${S3_ACCESS_KEY} -e S3_SECRET_KEY=${S3_SECRET_KEY}") { |
| 23 | common.retry(3, 5) { |
Ivan Udovichenko | 038b81f | 2020-10-05 23:57:27 +0300 | [diff] [blame] | 24 | sh(script: "wget --progress=dot:giga --tries=50 -O ${filename} ${url}", returnStdout: true) |
Ivan Udovichenko | 26208ed | 2020-10-29 16:59:09 +0300 | [diff] [blame^] | 25 | sh(script: "/usr/local/bin/s4cmd put ${opts} ${filename} ${DEST}/${filenamePath}", returnStdout: true) |
Kirill Mashchenko | da53589 | 2018-09-05 11:05:52 +0300 | [diff] [blame] | 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | |
| 31 | } |
| 32 | sh("rm ${filename}") |
| 33 | } |
| 34 | } |
| 35 | deleteDir() |
| 36 | } |