blob: 92bea478fe30bb516f2e199ed33cb2d8826c75ba [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()
7
8node('docker') {
chnyda98e60692017-06-28 16:43:00 +02009 try {
10 def img = dockerLib.getImage("tcpcloud/debian-build-ubuntu-${DIST}")
chnydaa8d16342017-06-20 17:18:25 +020011
chnyda98e60692017-06-28 16:43:00 +020012 img.inside ("-u root:root") {
chnydaa8d16342017-06-20 17:18:25 +020013 sh("rm -rf * || true")
14 }
15
16 stage("checkout") {
17 git.checkoutGitRepository(
18 "jmx-exporter-${timestamp}",
19 "${SOURCE_URL}",
20 SOURCE_BRANCH,
21 SOURCE_CREDENTIALS,
22 true,
23 30,
24 1
25 )
26 }
27
chnyda98e60692017-06-28 16:43:00 +020028 img.inside ("-u root:root") {
29 stage("Build") {
30 sh("sed -i \"s/TIMESTAMP/${timestamp}/g\" \$(find -name pom.xml)")
31 sh("sudo apt-get update && sudo apt-get install -y openjdk-8-jdk maven")
32 sh("cd jmx-exporter-${timestamp} && mvn package")
33 }
34 }
chnydaa8d16342017-06-20 17:18:25 +020035
chnyda98e60692017-06-28 16:43:00 +020036 if (UPLOAD_APTLY.toBoolean()) {
37 stage("upload package") {
38 def buildSteps = [:]
39 def debFiles = sh script: "find -name *.deb", returnStdout: true
40 def debFilesArray = debFiles.trim().tokenize()
41 def workspace = common.getWorkspace()
42 for (int i = 0; i < debFilesArray.size(); i++) {
43 def debFile = debFilesArray[i];
44 buildSteps[debFiles[i]] = aptly.uploadPackageStep(
45 "${workspace}/"+debFile,
46 APTLY_URL,
47 APTLY_REPO,
48 true
49 )
chnydaa8d16342017-06-20 17:18:25 +020050 }
chnyda98e60692017-06-28 16:43:00 +020051 parallel buildSteps
chnydaa8d16342017-06-20 17:18:25 +020052 }
53
chnyda98e60692017-06-28 16:43:00 +020054 stage("publish") {
55 aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp)
56 aptly.publish(APTLY_URL)
chnydaa8d16342017-06-20 17:18:25 +020057 }
chnyda98e60692017-06-28 16:43:00 +020058 }
chnydaa8d16342017-06-20 17:18:25 +020059
chnyda98e60692017-06-28 16:43:00 +020060 img.inside ("-u root:root") {
61 sh("rm -rf * || true")
chnydaa8d16342017-06-20 17:18:25 +020062 }
63
64 } catch (Throwable e) {
65 // If there was an exception thrown, the build failed
66 currentBuild.result = "FAILURE"
67 throw e
68 } finally {
69 common.sendNotification(currentBuild.result,"",["slack"])
chnydaa8d16342017-06-20 17:18:25 +020070 }
71}