blob: 4d096ae6850793579cd518d6aab45f343e50848c [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}
Jakub Josefa63f9862018-01-11 17:58:38 +010012timeout(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 )
chnyda2cccb452017-04-07 11:34:57 +020028 }
Jakub Josefa63f9862018-01-11 17:58:38 +010029 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 Josefc5a223a2017-03-01 14:40:08 +010036 }
Jakub Josefa63f9862018-01-11 17:58:38 +010037 archiveArtifacts artifacts: "debs/${DIST}-${ARCH}/*.deb"
Jakub Josefc5a223a2017-03-01 14:40:08 +010038 }
Jakub Josefa63f9862018-01-11 17:58:38 +010039 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 Josefc5a223a2017-03-01 14:40:08 +010066 }
Jakub Josefa63f9862018-01-11 17:58:38 +010067 }
Jakub Josefd2efd7d2017-08-22 17:49:57 +020068}