Skip to content

Commit 88298b6

Browse files
committed
Update debian/Jenkinsfile to latest version from DebianRepository
1 parent dafbd49 commit 88298b6

1 file changed

Lines changed: 102 additions & 56 deletions

File tree

debian/Jenkinsfile

Lines changed: 102 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,133 @@
11
#!groovy
22

3-
String[] distributions = ['debian:bookworm', 'debian:trixie', 'ubuntu:jammy', 'ubuntu:noble']
3+
// Aktuální verze Pipeline: https://github.com/VitexSoftware/BuildImages/blob/main/Test/Jenkinsfile-parael
4+
5+
String[] distributions = [
6+
'debian:bookworm',
7+
'debian:trixie',
8+
'debian:forky',
9+
'ubuntu:jammy',
10+
'ubuntu:noble'
11+
]
412

513
String vendor = 'vitexsoftware'
6-
String distribution = ''
7-
//String distroFamily = ''
8-
String distroCodename = ''
9-
String ver = ''
14+
String imagePrefix = 'multiflexi-'
1015

1116
properties([
1217
copyArtifactPermission('*')
1318
])
14-
node() {
19+
20+
node {
1521
ansiColor('xterm') {
1622
stage('SCM Checkout') {
1723
checkout scm
1824
}
1925
}
2026
}
2127

22-
distributions.each {
23-
distribution = it
24-
25-
println "Dist:" + distribution
28+
def branches = [:]
2629

27-
def dist = distribution.split(':')
28-
distroCodename = dist[1]
30+
distributions.each { distro ->
31+
branches[distro] = {
32+
def (distroFamily, distroCode) = distro.split(':')
33+
def imageName = "${vendor}/${imagePrefix}${distroCode}:latest"
34+
def buildImage
35+
def artifacts = []
36+
def buildVer
2937

30-
def buildImage = ''
38+
node {
39+
ansiColor('xterm') {
40+
stage("Checkout ${distro}") {
41+
checkout scm
42+
buildImage = docker.image(imageName)
3143

32-
def artifacts = []
33-
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}'",
44+
sh 'git checkout debian/changelog'
45+
buildVer = sh(
46+
script: "dpkg-parsechangelog --show-field Version",
5547
returnStdout: true
56-
).trim().split('\n')
48+
).trim() + ".${env.BUILD_NUMBER}~${distroCode}"
49+
}
50+
51+
stage("Build ${distro}") {
52+
buildImage.inside {
53+
sh """
54+
dch -b -v ${buildVer} "${env.BUILD_TAG}"
55+
sudo apt-get update --allow-releaseinfo-change
56+
sudo chown jenkins:jenkins ..
57+
debuild-pbuilder -i -us -uc -b
58+
mkdir -p \$WORKSPACE/dist/debian/
59+
rm -rf \$WORKSPACE/dist/debian/*
60+
for deb in \$(awk '{print \$1}' debian/files); do
61+
mv "../\$deb" \$WORKSPACE/dist/debian/
62+
done
63+
"""
64+
artifacts = sh(
65+
script: "awk '{print \$1}' debian/files",
66+
returnStdout: true
67+
).trim().split('\n')
68+
}
5769
}
58-
}
5970

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+
stage("Test ${distro}") {
72+
buildImage.inside {
73+
def debconf_debug = 0
74+
sh """
75+
cd \$WORKSPACE/dist/debian/
76+
dpkg-scanpackages . /dev/null > Packages
77+
gzip -9c Packages > Packages.gz
78+
cd \$WORKSPACE
79+
echo "deb [trusted=yes] file://///\$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list
80+
sudo apt-get update --allow-releaseinfo-change
81+
"""
82+
artifacts.each { deb_file ->
83+
if (deb_file.endsWith('.deb')) {
84+
def pkgName = deb_file.tokenize('/')[-1].replaceFirst(/_.*/, '')
85+
def distroCodename = sh(
86+
script: "lsb_release -sc",
87+
returnStdout: true
88+
).trim()
89+
echo "Installing ${pkgName} on ${distroCodename}"
90+
sh """
91+
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=${debconf_debug} \
92+
apt-get -y install ${pkgName} \
93+
|| sudo apt-get -y -f install
94+
"""
95+
}
7196
}
7297
}
7398
}
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
99+
100+
stage("Archive artifacts ${distro}") {
101+
buildImage.inside {
102+
artifacts.each { deb_file ->
103+
println "Archiving artifact: ${deb_file}"
104+
archiveArtifacts artifacts: "dist/debian/${deb_file}"
105+
}
106+
107+
sh '''
108+
set -e
109+
if [ -f debian/files ]; then
110+
while read -r file _; do
111+
[ -n "$file" ] || continue
112+
rm -f "dist/debian/$file" || true
113+
rm -f "../$file" || true
114+
rm -f "$WORKSPACE/$file" || true
115+
done < debian/files
116+
fi
117+
'''
80118
}
81-
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
82119
}
120+
83121
}
84122
}
85123
}
86124
}
87125

126+
127+
parallel branches
128+
129+
node {
130+
stage('Publish to Aptly') {
131+
publishDebToAptly()
132+
}
133+
}

0 commit comments

Comments
 (0)