Skip to content

Commit 6624266

Browse files
committed
Jenkinsfile added
1 parent 1e052b2 commit 6624266

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

Jenkinsfile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!groovy
2+
3+
// Unsupported by Docker: Trixie
4+
5+
String[] distributions = ['debian:bullseye', 'debian:bookworm', 'debian:trixie', 'ubuntu:jammy', 'ubuntu:noble']
6+
7+
String vendor = 'vitexsoftware'
8+
String distribution = ''
9+
String distroFamily = ''
10+
String distroCodename = ''
11+
String ver = ''
12+
13+
properties([
14+
copyArtifactPermission('*')
15+
])
16+
node() {
17+
ansiColor('xterm') {
18+
stage('SCM Checkout') {
19+
checkout scm
20+
}
21+
}
22+
}
23+
24+
distributions.each {
25+
distribution = it
26+
27+
println "Dist:" + distribution
28+
29+
def dist = distribution.split(':')
30+
distroFamily = dist[0]
31+
distroCodename = dist[1]
32+
33+
def buildImage = ''
34+
35+
def artifacts = []
36+
37+
node {
38+
ansiColor('xterm') {
39+
stage('Checkout ' + distribution) {
40+
checkout scm
41+
buildImage = docker.image(vendor + '/' + distribution)
42+
sh 'git checkout debian/changelog'
43+
def version = sh (
44+
script: 'dpkg-parsechangelog --show-field Version',
45+
returnStdout: true
46+
).trim()
47+
ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename
48+
}
49+
stage('Build ' + distribution) {
50+
buildImage.inside {
51+
sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"'
52+
sh 'sudo chown jenkins:jenkins ..'
53+
sh 'debuild-pbuilder -i -us -uc -b'
54+
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'
55+
artifacts = sh (
56+
script: "cat debian/files | awk '{print \$1}'",
57+
returnStdout: true
58+
).trim().split('\n')
59+
}
60+
}
61+
62+
stage('Test ' + distribution) {
63+
buildImage.inside {
64+
def debconf_debug = 5 //Set to "5" or "developer" to debug debconf
65+
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE'
66+
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
67+
sh 'sudo apt-get update --allow-releaseinfo-change'
68+
sh 'echo "INSTALATION"'
69+
artifacts.each { deb_file ->
70+
if (deb_file.endsWith('.deb')) {
71+
sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "'
72+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file
73+
}
74+
}
75+
}
76+
}
77+
stage('Copy artifacts ' + distribution ) {
78+
buildImage.inside {
79+
artifacts.each { deb_file ->
80+
println "Copying artifact: " + deb_file
81+
archiveArtifacts artifacts: 'dist/debian/' + deb_file
82+
}
83+
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
84+
}
85+
}
86+
}
87+
}
88+
}
89+

0 commit comments

Comments
 (0)