Skip to content

Commit dd3483f

Browse files
committed
Refactor Jenkinsfile to streamline distribution handling and remove architecture logic
1 parent 64bcf3e commit dd3483f

File tree

1 file changed

+50
-63
lines changed

1 file changed

+50
-63
lines changed

debian/Jenkinsfile

Lines changed: 50 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
#!groovy
22

3-
4-
String[] architectures = []
5-
String[] distributions = ['debian:buster', 'debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:hirsute', 'ubuntu:impish']
3+
String[] distributions = ['debian:bookworm', 'debian:trixie', 'ubuntu:jammy', 'ubuntu:noble']
64

75
String vendor = 'vitexsoftware'
86
String distribution = ''
9-
String architecture = ''
107
//String distroFamily = ''
118
String distroCodename = ''
129
String ver = ''
@@ -18,79 +15,69 @@ node() {
1815
ansiColor('xterm') {
1916
stage('SCM Checkout') {
2017
checkout scm
21-
def control = readFile( file: env.WORKSPACE + "/debian/control")
22-
def lines = control.readLines()
23-
for(line in lines) {
24-
if (line.trim()) {
25-
def (key,value) = line.split(': ').collect { it.trim() }
26-
if ( key == 'Architecture' ) {
27-
28-
if (value == 'any') {
29-
architectures = ['amd64', 'armhf', 'aarch64']
30-
} else {
31-
architectures = [value]
32-
}
33-
}
34-
}
35-
}
36-
3718
}
3819
}
3920
}
4021

22+
distributions.each {
23+
distribution = it
4124

25+
println "Dist:" + distribution
4226

43-
architectures.each {
44-
architecture = it
45-
46-
println "Arch: " + architecture
27+
def dist = distribution.split(':')
28+
distroCodename = dist[1]
4729

48-
distributions.each {
49-
distribution = it
30+
def buildImage = ''
5031

51-
println "Dist:" + distribution
32+
def artifacts = []
5233

53-
def dist = distribution.split(':')
54-
// distroFamily = dist[0]
55-
distroCodename = dist[1]
56-
57-
def buildImage = ''
58-
59-
node( architecture ) {
60-
ansiColor('xterm') {
61-
stage('Checkout ' + architecture + ' ' + distribution) {
62-
buildImage = docker.image(vendor + '/' + distribution)
63-
sh 'git checkout debian/changelog'
64-
def VERSION = sh (
65-
script: 'dpkg-parsechangelog --show-field Version',
34+
node {
35+
ansiColor('xterm') {
36+
stage('Checkout ' + distribution) {
37+
checkout scm
38+
buildImage = docker.image(vendor + '/' + distribution)
39+
sh 'git checkout debian/changelog'
40+
def version = sh (
41+
script: 'dpkg-parsechangelog --show-field Version',
42+
returnStdout: true
43+
).trim()
44+
ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename
45+
}
46+
stage('Build ' + distribution) {
47+
buildImage.inside {
48+
sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"'
49+
sh 'sudo apt-get update --allow-releaseinfo-change'
50+
sh 'sudo chown jenkins:jenkins ..'
51+
sh 'debuild-pbuilder -i -us -uc -b'
52+
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'
53+
artifacts = sh (
54+
script: "cat debian/files | awk '{print \$1}'",
6655
returnStdout: true
67-
).trim()
68-
ver = VERSION + '~' + distroCodename + '~' + env.BUILD_NUMBER
69-
}
70-
stage('Build ' + architecture + ' ' + distribution) {
71-
buildImage.inside {
72-
sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"'
73-
sh 'sudo apt-get update'
74-
sh 'sudo chown jenkins:jenkins ..'
75-
sh 'debuild-pbuilder -i -us -uc -b'
76-
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'
77-
}
56+
).trim().split('\n')
7857
}
58+
}
7959

80-
stage('Test ' + architecture + ' ' + distribution) {
81-
buildImage.inside {
82-
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
83-
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE'
84-
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
85-
sh 'sudo apt-get update'
86-
sh 'echo "INSTALATION"'
87-
sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | awk -F_ \'{print \$1}\'` ; do echo -e "${GREEN} installing ${package} on `lsb_release -sc` ${ENDCOLOR} " ; sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $package ; echo "test now"; done;'
88-
stash includes: 'dist/**', name: 'dist-' + distroCodename
60+
stage('Test ' + distribution) {
61+
buildImage.inside {
62+
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
63+
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE'
64+
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
65+
sh 'sudo apt-get update --allow-releaseinfo-change'
66+
sh 'echo "INSTALATION"'
67+
artifacts.each { deb_file ->
68+
if (deb_file.endsWith('.deb')) {
69+
sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "'
70+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file
71+
}
8972
}
9073
}
91-
stage('Copy artifacts ' + architecture + ' ' + distribution ) {
92-
buildImage.inside {
93-
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
74+
}
75+
stage('Copy artifacts ' + distribution ) {
76+
buildImage.inside {
77+
artifacts.each { deb_file ->
78+
println "Copying artifact: " + deb_file
79+
archiveArtifacts artifacts: 'dist/debian/' + deb_file
80+
sh 'cp $WORKSPACE/dist/debian/' + deb_file + ' $WORKSPACE'
9481
}
9582
}
9683
}

0 commit comments

Comments
 (0)