blob: d6e7fbdef0c75bec49ffbf677cd8e6516f720cac [file] [log] [blame]
chnydaa8d16342017-06-20 17:18:25 +02001def common = new com.mirantis.mk.Common()
2def git = new com.mirantis.mk.Git()
3def aptly = new com.mirantis.mk.Aptly()
chnyda98e60692017-06-28 16:43:00 +02004def dockerLib = new com.mirantis.mk.Docker()
chnydaa8d16342017-06-20 17:18:25 +02005
6def timestamp = common.getDatetime()
Olivier Bourdon8e1e6bd2017-06-29 12:20:36 +02007def javaversion = "8"
Jakub Josefa63f9862018-01-11 17:58:38 +01008timeout(time: 12, unit: 'HOURS') {
9 node('docker') {
10 try {
11 def img = dockerLib.getImage("tcpcloud/debian-build-ubuntu-${DIST}")
chnydaa8d16342017-06-20 17:18:25 +020012
Jakub Josefa63f9862018-01-11 17:58:38 +010013 if ("${DIST}" == "trusty") {
14 javaversion = "7"
chnyda98e60692017-06-28 16:43:00 +020015 }
chnydaa8d16342017-06-20 17:18:25 +020016
Jakub Josefa63f9862018-01-11 17:58:38 +010017 img.inside ("-u root:root") {
18 sh("rm -rf * || true")
19 }
20
21 stage("checkout") {
22 git.checkoutGitRepository(
23 "jmx-exporter-${timestamp}",
24 "${SOURCE_URL}",
25 SOURCE_BRANCH,
26 SOURCE_CREDENTIALS,
27 true,
28 30,
29 1
30 )
31 }
32
33 img.inside ("-u root:root") {
34 stage("Build") {
35 sh("sed -i \"s/TIMESTAMP/${timestamp}/g\" \$(find ./ -name pom.xml)")
36 sh("sudo apt-get update && sudo apt-get install -y openjdk-${javaversion}-jdk maven")
37 sh("cd jmx-exporter-${timestamp} && mvn package")
chnydaa8d16342017-06-20 17:18:25 +020038 }
39 }
40
Jakub Josefa63f9862018-01-11 17:58:38 +010041 if (UPLOAD_APTLY.toBoolean()) {
42 stage("upload package") {
43 def buildSteps = [:]
44 def debFiles = sh script: "find ./ -name *.deb", returnStdout: true
45 def debFilesArray = debFiles.trim().tokenize()
46 def workspace = common.getWorkspace()
47 for (int i = 0; i < debFilesArray.size(); i++) {
48 def debFile = debFilesArray[i];
49 buildSteps[debFiles[i]] = aptly.uploadPackageStep(
50 "${workspace}/"+debFile,
51 APTLY_URL,
52 APTLY_REPO,
53 true
54 )
55 }
56 parallel buildSteps
57 }
58
59 stage("publish") {
60 aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp)
61 aptly.publish(APTLY_URL)
62 }
chnydaa8d16342017-06-20 17:18:25 +020063 }
64
Jakub Josefa63f9862018-01-11 17:58:38 +010065 img.inside ("-u root:root") {
66 sh("rm -rf * || true")
67 }
chnydaa8d16342017-06-20 17:18:25 +020068
Jakub Josefa63f9862018-01-11 17:58:38 +010069 } catch (Throwable e) {
70 // If there was an exception thrown, the build failed
71 currentBuild.result = "FAILURE"
72 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
73 throw e
74 } finally {
75 common.sendNotification(currentBuild.result,"",["slack"])
76 }
chnydaa8d16342017-06-20 17:18:25 +020077 }
78}