chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 1 | def common = new com.mirantis.mk.Common() |
| 2 | def git = new com.mirantis.mk.Git() |
| 3 | def aptly = new com.mirantis.mk.Aptly() |
chnyda | 98e6069 | 2017-06-28 16:43:00 +0200 | [diff] [blame] | 4 | def dockerLib = new com.mirantis.mk.Docker() |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 5 | |
| 6 | def timestamp = common.getDatetime() |
Olivier Bourdon | 8e1e6bd | 2017-06-29 12:20:36 +0200 | [diff] [blame] | 7 | def javaversion = "8" |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 8 | timeout(time: 12, unit: 'HOURS') { |
| 9 | node('docker') { |
| 10 | try { |
| 11 | def img = dockerLib.getImage("tcpcloud/debian-build-ubuntu-${DIST}") |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 12 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 13 | if ("${DIST}" == "trusty") { |
| 14 | javaversion = "7" |
chnyda | 98e6069 | 2017-06-28 16:43:00 +0200 | [diff] [blame] | 15 | } |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 16 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 17 | 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") |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 38 | } |
| 39 | } |
| 40 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 41 | 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 Josef | 01719f7 | 2018-03-26 12:28:49 +0200 | [diff] [blame] | 61 | retry(2){ |
| 62 | aptly.publish(APTLY_URL) |
| 63 | } |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 64 | } |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 65 | } |
| 66 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 67 | img.inside ("-u root:root") { |
| 68 | sh("rm -rf * || true") |
| 69 | } |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 70 | |
Jakub Josef | a63f986 | 2018-01-11 17:58:38 +0100 | [diff] [blame] | 71 | } 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 | } |
chnyda | a8d1634 | 2017-06-20 17:18:25 +0200 | [diff] [blame] | 79 | } |
| 80 | } |