blob: 976272c38ed37979a7e4ce211919b37a00528037 [file] [log] [blame]
Kirill Mashchenkoda535892018-09-05 11:05:52 +03001def common = new com.mirantis.mk.Common()
Ivan Udovichenko26208ed2020-10-29 16:59:09 +03002def s4cmdOpts = ' --sync-check '
3Boolean forceUpload = (env.FORCE_UPLOAD ?: false).toBoolean()
Kirill Mashchenkoda535892018-09-05 11:05:52 +03004
5node("docker") {
6 stage('Prepare') {
7 img = docker.image(IMAGE)
8 img.pull()
9 }
10 stage('Upload') {
Ivan Udovichenko26208ed2020-10-29 16:59:09 +030011 FILENAMES.split().each { filenamePath ->
12 url = "${SOURCE}/${filenamePath}"
13 filename = filenamePath.tokenize('/')[-1]
azvyagintsevac363ef2018-11-23 20:13:08 +020014 opts = s4cmdOpts
Ivan Udovichenko26208ed2020-10-29 16:59:09 +030015 if(filenamePath.contains('stable') || forceUpload) {
16 common.warningMsg("Going to ovveride ${filenamePath}")
azvyagintsevac363ef2018-11-23 20:13:08 +020017 opts = opts + '--force'
18 }
Kirill Mashchenkoda535892018-09-05 11:05:52 +030019 img.withRun("--entrypoint='/bin/bash'") { c ->
Ivan Udovichenko26208ed2020-10-29 16:59:09 +030020 withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'aws-s3',
Kirill Mashchenkoda535892018-09-05 11:05:52 +030021 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 Udovichenko038b81f2020-10-05 23:57:27 +030024 sh(script: "wget --progress=dot:giga --tries=50 -O ${filename} ${url}", returnStdout: true)
Ivan Udovichenko26208ed2020-10-29 16:59:09 +030025 sh(script: "/usr/local/bin/s4cmd put ${opts} ${filename} ${DEST}/${filenamePath}", returnStdout: true)
Kirill Mashchenkoda535892018-09-05 11:05:52 +030026 }
27 }
28 }
29
30
31 }
32 sh("rm ${filename}")
33 }
34 }
35 deleteDir()
36}