-
Notifications
You must be signed in to change notification settings - Fork 8
/
Jenkinsfile
87 lines (76 loc) · 3.23 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
81
82
83
84
85
86
#!groovy
String[] distributions = ['debian:bullseye', 'debian:bookworm', 'debian:trixie', 'ubuntu:focal', 'ubuntu:jammy', 'ubuntu:noble']
String vendor = 'vitexsoftware'
String distribution = ''
//String distroFamily = ''
String distroCodename = ''
String ver = ''
properties([
copyArtifactPermission('*')
])
node() {
ansiColor('xterm') {
stage('SCM Checkout') {
checkout scm
}
}
}
distributions.each {
distribution = it
println "Dist:" + distribution
def dist = distribution.split(':')
distroCodename = dist[1]
def buildImage = ''
def artifacts = []
node {
ansiColor('xterm') {
stage('Checkout ' + distribution) {
checkout scm
buildImage = docker.image(vendor + '/' + distribution)
sh 'git checkout debian/changelog'
def version = sh (
script: 'dpkg-parsechangelog --show-field Version',
returnStdout: true
).trim()
ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename
}
stage('Build ' + distribution) {
buildImage.inside {
sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"'
sh 'sudo apt-get update --allow-releaseinfo-change'
sh 'sudo chown jenkins:jenkins ..'
sh 'debuild-pbuilder -i -us -uc -b'
sh 'mkdir -p $WORKSPACE/dist/debian/ ; rm -rf $WORKSPACE/dist/debian/* ; for deb in $(cat debian/files | awk \'{print $1}\'); do mv "../$deb" $WORKSPACE/dist/debian/; done'
artifacts = sh (
script: "cat debian/files | awk '{print \$1}'",
returnStdout: true
).trim().split('\n')
}
}
stage('Test ' + distribution) {
buildImage.inside {
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE'
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
sh 'sudo apt-get update --allow-releaseinfo-change'
sh 'echo "INSTALATION"'
artifacts.each { deb_file ->
if (deb_file.endsWith('.deb')) {
sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "'
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file
}
}
}
}
stage('Copy artifacts ' + distribution ) {
buildImage.inside {
artifacts.each { deb_file ->
println "Copying artifact: " + deb_file
archiveArtifacts artifacts: 'dist/debian/' + deb_file
}
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
}
}
}
}
}