-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathJenkinsfile
80 lines (77 loc) · 2.94 KB
/
Jenkinsfile
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
71
72
73
74
75
76
77
78
79
80
node {
def RELEASETYPE
def WORKSPACE
def PROJECTDIR
def INCREMENTCOMMAND
def DATE
def GIT_COMMIT
// TODO can we generate the version from ${env.BUILD_NUMBER} and still pass debian linters
stage('Preparation') { // for display purposes
git branch: env.gitbranch, url: 'https://github.com/christf/snapcastc.git'
if (params.DEBUG) {
RELEASETYPE = "Debug"
DATE = sh (
script: 'date',
returnStdout: true
).trim()
GIT_COMMIT = sh (
script: 'git log -n 1 --pretty=format:"%h"',
returnStdout: true
).trim()
INCREMENTCOMMAND = " && dch -l ${env.BUILD_NUMBER} \"local Build at ${DATE} for commit ${GIT_COMMIT}\""
}
else {
RELEASETYPE = "Release"
}
sh "./scripts/builddockerfile"
sh "docker build -t snapcastc-build ."
sh "pwd > workspace"
WORKSPACE = readFile('workspace').trim()
PROJECTDIR = "snapcastc"
sh "rm -rf deb build; mkdir deb"
}
stage('Build') {
if (isUnix()) {
sh "docker run -u `id -u $USER` -v $WORKSPACE:/$PROJECTDIR -a STDIN -a STDOUT -a STDERR snapcastc-build /bin/sh -c 'rm -rf /$PROJECTDIR/build; mkdir -p /$PROJECTDIR/build && cd /$PROJECTDIR/build && cmake -DCMAKE_BUILD_TYPE=$RELEASETYPE .. && make -j5'"
}
}
stage('Test') {
parallel (
'Test Client': {
sh "docker run -v $WORKSPACE:/$PROJECTDIR -a STDIN -a STDOUT -a STDERR snapcastc-build /$PROJECTDIR/build/src/snapcast-test-client > testlog-client 2>&1"
sh "cat testlog-client"
},
'Test Server': {
sh "docker run -v $WORKSPACE:/$PROJECTDIR -a STDIN -a STDOUT -a STDERR snapcastc-build /$PROJECTDIR/build/src/snapcast-test-srv > testlog-srv 2>&1"
sh "cat testlog-srv"
}
)
}
stage('Package') {
parallel (
'PackageX86': {
sh "mkdir -p deb/debian"
sh "docker run -v $WORKSPACE:/$PROJECTDIR -a STDIN -a STDOUT -a STDERR snapcastc-build /bin/sh -c 'cd /$PROJECTDIR/build $INCREMENTCOMMAND && ../scripts/make_debian_package && mv /*.deb /$PROJECTDIR/build/'"
sh "cp build/*.deb deb/debian"
sh "docker run -v $WORKSPACE:/$PROJECTDIR -a STDIN -a STDOUT -a STDERR snapcastc-build /bin/sh -c 'rm -rf /$PROJECTDIR/build/'"
},
'PackageARM': {
sh "mkdir -p deb/raspbian"
sh "ssh pi@wohnzimmer 'rm -rf /tmp/snapcastc; cd /tmp; git clone https://github.com/christf/snapcastc.git; mkdir snapcastc/build; cd snapcastc/build $INCREMENTCOMMAND &&../scripts/make_debian_package'"
sh "scp 'pi@wohnzimmer:/tmp/snapcastc_*.deb' deb/raspbian; ssh pi@wohnzimmer 'rm -rf /tmp/snapcastc*'"
}
)
}
stage('Upload') {
sh "/usr/local/bin/package_cloud push christf/dev/debian/bullseye deb/debian/*.deb"
sh "/usr/local/bin/package_cloud push christf/dev/raspbian/bullseye deb/raspbian/*.deb"
}
stage('Results') {
archiveArtifacts 'deb/*/*.deb'
archiveArtifacts 'testlog'
}
stage("Cleanup") {
sh "rm -f testlog"
sh "docker run -v $WORKSPACE:/$PROJECTDIR -a STDIN -a STDOUT -a STDERR snapcastc-build rm -rf /$PROJECTDIR/build"
}
}