Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame^] | 1 | def common = new com.mirantis.mk.Common() |
| 2 | def aptly = new com.mirantis.mk.Aptly() |
| 3 | def timestamp = common.getDatetime() |
| 4 | |
| 5 | node("docker") { |
| 6 | try { |
| 7 | stage("checkout") { |
| 8 | sh("test -d debs && rm -rf debs || true") |
| 9 | sh("test -d build && rm -rf build || true") |
| 10 | git poll: false, url: SOURCE_URL, branch: SOURCE_BRANCH, credentialsId: SOURCE_CREDENTIALS |
| 11 | } |
| 12 | stage("build") { |
| 13 | sh("docker run -v "+common.getWorkspace()+":"+common.getWorkspace()+" -w "+common.getWorkspace()+" --rm=true --privileged "+OS+":"+DIST+" /bin/bash -c 'apt-get update && apt-get install -y packaging-dev && ./build-debs.sh "+DIST+"'") |
| 14 | archiveArtifacts artifacts: "debs/"+DIST+"-"+ARCH+"/*.deb" |
| 15 | } |
| 16 | lock("aptly-api") { |
| 17 | stage("upload") { |
| 18 | buildSteps = [:] |
| 19 | debFiles = sh script: "ls debs/"+DIST+"-"+ARCH+"/*.deb", returnStdout: true |
| 20 | for (file in debFiles.tokenize()) { |
| 21 | workspace = common.getWorkspace() |
| 22 | def fh = new File((workspace+"/"+file).trim()) |
| 23 | buildSteps[fh.name.split('_')[0]] = aptly.uploadPackageStep( |
| 24 | "debs/"+DIST+"-"+ARCH+"/"+fh.name, |
| 25 | APTLY_URL, |
| 26 | APTLY_REPO, |
| 27 | true |
| 28 | ) |
| 29 | } |
| 30 | parallel buildSteps |
| 31 | } |
| 32 | stage("publish") { |
| 33 | aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp) |
| 34 | aptly.publish(APTLY_URL) |
| 35 | } |
| 36 | } |
| 37 | } catch (Throwable e) { |
| 38 | // If there was an error or exception thrown, the build failed |
| 39 | currentBuild.result = "FAILURE" |
| 40 | throw e |
| 41 | } finally { |
| 42 | common.sendNotification(currentBuild.result,"",["slack"]) |
| 43 | } |
| 44 | } |