-
Notifications
You must be signed in to change notification settings - Fork 46
/
build-extra-dpdk-pipeline.groovy
70 lines (69 loc) · 2.61 KB
/
build-extra-dpdk-pipeline.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def common = new com.mirantis.mk.Common()
def aptly = new com.mirantis.mk.Aptly()
def git = new com.mirantis.mk.Git()
def timestamp = common.getDatetime()
def binaryPackages
try {
binaryPackages = BINARY_PACKAGES
} catch (MissingPropertyException e) {
binaryPackages = ""
}
timeout(time: 12, unit: 'HOURS') {
node("docker") {
try {
def workspace = common.getWorkspace()
stage("checkout") {
sh("test -d debs && rm -rf debs || true")
sh("test -d build && rm -rf build || true")
git.checkoutGitRepository(
".",
SOURCE_URL,
SOURCE_BRANCH,
SOURCE_CREDENTIALS,
false,
30,
1
)
}
stage("build") {
if (binaryPackages == "all" || binaryPackages == "") {
sh("docker run -v " + workspace + ":" + workspace + " -w " + workspace + " --rm=true --privileged "+OS+":" + DIST +
" /bin/bash -c 'apt-get update && apt-get install -y packaging-dev && ./build-debs.sh " + DIST + "'")
} else {
sh("docker run -v " + workspace + ":" + workspace + " -w " + workspace + " --rm=true --privileged "+OS+":" + DIST +
" /bin/bash -c 'apt-get update && apt-get install -y packaging-dev && ./build-debs.sh " + DIST + " " + binaryPackages + "'")
}
archiveArtifacts artifacts: "debs/${DIST}-${ARCH}/*.deb"
}
lock("aptly-api") {
stage("upload") {
buildSteps = [:]
debFiles = sh script: "ls debs/"+DIST+"-"+ARCH+"/*.deb", returnStdout: true
for (file in debFiles.tokenize()) {
def fh = new File((workspace+"/"+file).trim())
buildSteps[fh.name.split('_')[0]] = aptly.uploadPackageStep(
"debs/"+DIST+"-"+ARCH+"/"+fh.name,
APTLY_URL,
APTLY_REPO,
true
)
}
parallel buildSteps
}
stage("publish") {
aptly.snapshotRepo(APTLY_URL, APTLY_REPO, timestamp)
retry(2){
aptly.publish(APTLY_URL)
}
}
}
} catch (Throwable e) {
// If there was an error or exception thrown, the build failed
currentBuild.result = "FAILURE"
currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message
throw e
} finally {
common.sendNotification(currentBuild.result,"",["slack"])
}
}
}