blob: d356f699a798b2a32fff7d3d03de9e080c867511 [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"
chnydaa8d16342017-06-20 17:18:25 +02008
9node('docker') {
chnyda98e60692017-06-28 16:43:00 +020010 try {
11 def img = dockerLib.getImage("tcpcloud/debian-build-ubuntu-${DIST}")
chnydaa8d16342017-06-20 17:18:25 +020012
Olivier Bourdon8e1e6bd2017-06-29 12:20:36 +020013 if ("${DIST}" == "trusty") {
14 javaversion = "7"
15 }
16
chnyda98e60692017-06-28 16:43:00 +020017 img.inside ("-u root:root") {
chnydaa8d16342017-06-20 17:18:25 +020018 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
chnyda98e60692017-06-28 16:43:00 +020033 img.inside ("-u root:root") {
34 stage("Build") {
Olivier Bourdon995e7f32017-06-29 12:23:12 +020035 sh("sed -i \"s/TIMESTAMP/${timestamp}/g\" \$(find ./ -name pom.xml)")
Olivier Bourdon8e1e6bd2017-06-29 12:20:36 +020036 sh("sudo apt-get update && sudo apt-get install -y openjdk-${javaversion}-jdk maven")
chnyda98e60692017-06-28 16:43:00 +020037 sh("cd jmx-exporter-${timestamp} && mvn package")
38 }
39 }
chnydaa8d16342017-06-20 17:18:25 +020040
chnyda98e60692017-06-28 16:43:00 +020041 if (UPLOAD_APTLY.toBoolean()) {
42 stage("upload package") {
43 def buildSteps = [:]
Olivier Bourdon995e7f32017-06-29 12:23:12 +020044 def debFiles = sh script: "find ./ -name *.deb", returnStdout: true
chnyda98e60692017-06-28 16:43:00 +020045 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 )
chnydaa8d16342017-06-20 17:18:25 +020055 }
chnyda98e60692017-06-28 16:43:00 +020056 parallel buildSteps
chnydaa8d16342017-06-20 17:18:25 +020057 }
58
chnyda98e60692017-06-28 16:43:00 +020059 stage("publish") {
60 aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp)
61 aptly.publish(APTLY_URL)
chnydaa8d16342017-06-20 17:18:25 +020062 }
chnyda98e60692017-06-28 16:43:00 +020063 }
chnydaa8d16342017-06-20 17:18:25 +020064
chnyda98e60692017-06-28 16:43:00 +020065 img.inside ("-u root:root") {
66 sh("rm -rf * || true")
chnydaa8d16342017-06-20 17:18:25 +020067 }
68
69 } catch (Throwable e) {
70 // If there was an exception thrown, the build failed
71 currentBuild.result = "FAILURE"
72 throw e
73 } finally {
74 common.sendNotification(currentBuild.result,"",["slack"])
chnydaa8d16342017-06-20 17:18:25 +020075 }
76}