blob: eaa9f05cc9f4b6dcc00f5d4986fa616c4308fbc1 [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)
Jakub Josef01719f72018-03-26 12:28:49 +020061 retry(2){
62 aptly.publish(APTLY_URL)
63 }
Jakub Josefa63f9862018-01-11 17:58:38 +010064 }
chnydaa8d16342017-06-20 17:18:25 +020065 }
66
Jakub Josefa63f9862018-01-11 17:58:38 +010067 img.inside ("-u root:root") {
68 sh("rm -rf * || true")
69 }
chnydaa8d16342017-06-20 17:18:25 +020070
Jakub Josefa63f9862018-01-11 17:58:38 +010071 } catch (Throwable e) {
72 // If there was an exception thrown, the build failed
73 currentBuild.result = "FAILURE"
74 currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
75 throw e
76 } finally {
77 common.sendNotification(currentBuild.result,"",["slack"])
78 }
chnydaa8d16342017-06-20 17:18:25 +020079 }
80}