blob: 39928dc288d07479715a1e904ca8c03b8e9adf89 [file] [log] [blame]
Jakub Josefc5a223a2017-03-01 14:40:08 +01001def common = new com.mirantis.mk.Common()
2def aptly = new com.mirantis.mk.Aptly()
chnyda2cccb452017-04-07 11:34:57 +02003def git = new com.mirantis.mk.Git()
Jakub Josefc5a223a2017-03-01 14:40:08 +01004def timestamp = common.getDatetime()
5
chnyda2cccb452017-04-07 11:34:57 +02006def binaryPackages
7try {
8 binaryPackages = BINARY_PACKAGES
9} catch (MissingPropertyException e) {
10 binaryPackages = ""
11}
12
Jakub Josefc5a223a2017-03-01 14:40:08 +010013node("docker") {
14 try {
chnyda2cccb452017-04-07 11:34:57 +020015 def workspace = common.getWorkspace()
Jakub Josefc5a223a2017-03-01 14:40:08 +010016 stage("checkout") {
17 sh("test -d debs && rm -rf debs || true")
18 sh("test -d build && rm -rf build || true")
chnyda2cccb452017-04-07 11:34:57 +020019 git.checkoutGitRepository(
20 ".",
21 SOURCE_URL,
22 SOURCE_BRANCH,
23 SOURCE_CREDENTIALS,
24 false,
25 30,
26 1
27 )
Jakub Josefc5a223a2017-03-01 14:40:08 +010028 }
29 stage("build") {
chnyda2cccb452017-04-07 11:34:57 +020030 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 + "'")
36 }
37 archiveArtifacts artifacts: "debs/${DIST}-${ARCH}/*.deb"
Jakub Josefc5a223a2017-03-01 14:40:08 +010038 }
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()) {
Jakub Josefc5a223a2017-03-01 14:40:08 +010044 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 throw e
63 } finally {
64 common.sendNotification(currentBuild.result,"",["slack"])
65 }
66}