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() |
chnyda | 2cccb45 | 2017-04-07 11:34:57 +0200 | [diff] [blame] | 3 | def git = new com.mirantis.mk.Git() |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 4 | def timestamp = common.getDatetime() |
| 5 | |
chnyda | 2cccb45 | 2017-04-07 11:34:57 +0200 | [diff] [blame] | 6 | def binaryPackages |
| 7 | try { |
| 8 | binaryPackages = BINARY_PACKAGES |
| 9 | } catch (MissingPropertyException e) { |
| 10 | binaryPackages = "" |
| 11 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 12 | timeout(time: 12, unit: 'HOURS') { |
| 13 | node("docker") { |
| 14 | try { |
| 15 | def workspace = common.getWorkspace() |
| 16 | stage("checkout") { |
| 17 | sh("test -d debs && rm -rf debs || true") |
| 18 | sh("test -d build && rm -rf build || true") |
| 19 | git.checkoutGitRepository( |
| 20 | ".", |
| 21 | SOURCE_URL, |
| 22 | SOURCE_BRANCH, |
| 23 | SOURCE_CREDENTIALS, |
| 24 | false, |
| 25 | 30, |
| 26 | 1 |
| 27 | ) |
chnyda | 2cccb45 | 2017-04-07 11:34:57 +0200 | [diff] [blame] | 28 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 29 | stage("build") { |
| 30 | if (binaryPackages == "all" || binaryPackages == "") { |
| 31 | sh("docker run -v " + workspace + ":" + workspace + " -w " + workspace + " --rm=true --privileged "+OS+":" + DIST + |
| 32 | " /bin/bash -c 'apt-get update && apt-get install -y packaging-dev && ./build-debs.sh " + DIST + "'") |
| 33 | } else { |
| 34 | sh("docker run -v " + workspace + ":" + workspace + " -w " + workspace + " --rm=true --privileged "+OS+":" + DIST + |
| 35 | " /bin/bash -c 'apt-get update && apt-get install -y packaging-dev && ./build-debs.sh " + DIST + " " + binaryPackages + "'") |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 36 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 37 | archiveArtifacts artifacts: "debs/${DIST}-${ARCH}/*.deb" |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 38 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 39 | lock("aptly-api") { |
| 40 | stage("upload") { |
| 41 | buildSteps = [:] |
| 42 | debFiles = sh script: "ls debs/"+DIST+"-"+ARCH+"/*.deb", returnStdout: true |
| 43 | for (file in debFiles.tokenize()) { |
| 44 | def fh = new File((workspace+"/"+file).trim()) |
| 45 | buildSteps[fh.name.split('_')[0]] = aptly.uploadPackageStep( |
| 46 | "debs/"+DIST+"-"+ARCH+"/"+fh.name, |
| 47 | APTLY_URL, |
| 48 | APTLY_REPO, |
| 49 | true |
| 50 | ) |
| 51 | } |
| 52 | parallel buildSteps |
| 53 | } |
| 54 | stage("publish") { |
| 55 | aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp) |
| 56 | aptly.publish(APTLY_URL) |
| 57 | } |
| 58 | } |
| 59 | } catch (Throwable e) { |
| 60 | // If there was an error or exception thrown, the build failed |
| 61 | currentBuild.result = "FAILURE" |
| 62 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 63 | throw e |
| 64 | } finally { |
| 65 | common.sendNotification(currentBuild.result,"",["slack"]) |
Jakub Josef | c5a223a | 2017-03-01 14:40:08 +0100 | [diff] [blame] | 66 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 67 | } |
Jakub Josef | d2efd7d | 2017-08-22 17:49:57 +0200 | [diff] [blame] | 68 | } |