Skip to content

Commit e1b5ec8

Browse files
author
automation
committed
ci: sync debian/Jenkinsfile.release from reference
1 parent 7d38158 commit e1b5ec8

1 file changed

Lines changed: 114 additions & 0 deletions

File tree

debian/Jenkinsfile.release

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!groovy
2+
3+
String[] distributions = ['debian:bookworm', 'debian:trixie', 'debian:forky', 'ubuntu:jammy', 'ubuntu:noble']
4+
5+
String vendor = 'vitexsoftware'
6+
String imagePrefix = 'multiflexi-'
7+
//String distroFamily = ''
8+
9+
properties([
10+
copyArtifactPermission('*')
11+
])
12+
node() {
13+
ansiColor('xterm') {
14+
stage('SCM Checkout') {
15+
checkout scm
16+
}
17+
}
18+
}
19+
20+
def branches = [:]
21+
distributions.each { distro ->
22+
branches[distro] = {
23+
def distroName = distro
24+
println "Dist:" + distroName
25+
26+
def dist = distroName.split(':')
27+
def distroCode = dist[1]
28+
def buildImage = ''
29+
def artifacts = []
30+
def buildVer = ''
31+
32+
node {
33+
ansiColor('xterm') {
34+
stage('Checkout ' + distroName) {
35+
checkout scm
36+
def imageName = vendor + '/' + imagePrefix + distroCode + ':latest'
37+
buildImage = docker.image(imageName)
38+
sh 'git checkout debian/changelog'
39+
def version = sh (
40+
script: 'dpkg-parsechangelog --show-field Version',
41+
returnStdout: true
42+
).trim()
43+
buildVer = version + '.' + env.BUILD_NUMBER + '~' + distroCode
44+
}
45+
stage('Build ' + distroName) {
46+
buildImage.inside {
47+
sh 'dch -b -v ' + buildVer + ' "' + env.BUILD_TAG + '"'
48+
sh 'sudo apt-get update --allow-releaseinfo-change'
49+
sh 'sudo chown jenkins:jenkins ..'
50+
sh 'debuild-pbuilder -i -us -uc -b'
51+
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'
52+
artifacts = sh (
53+
script: "cat debian/files | awk '{print \$1}'",
54+
returnStdout: true
55+
).trim().split('\n')
56+
}
57+
}
58+
59+
stage('Test ' + distroName) {
60+
buildImage.inside {
61+
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
62+
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE'
63+
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
64+
sh 'sudo apt-get update --allow-releaseinfo-change'
65+
sh 'echo "INSTALATION"'
66+
artifacts.each { deb_file ->
67+
if (deb_file.endsWith('.deb')) {
68+
sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "'
69+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file
70+
}
71+
}
72+
}
73+
}
74+
stage('Archive artifacts ' + distroName ) {
75+
// Only run if previous stages (Build and Test) succeeded
76+
buildImage.inside {
77+
// Archive all produced artifacts listed in debian/files
78+
artifacts.each { deb_file ->
79+
println "Archiving artifact: " + deb_file
80+
archiveArtifacts artifacts: 'dist/debian/' + deb_file
81+
}
82+
// Cleanup: remove any produced files named in debian/files
83+
// Try both the dist location and any potential original locations referenced by debian/files
84+
sh """
85+
set -e
86+
if [ -f debian/files ]; then
87+
while read -r f _; do
88+
[ -n "$f" ] || continue
89+
rm -f "dist/debian/$f" || true
90+
rm -f "../$f" || true
91+
rm -f "$WORKSPACE/$f" || true
92+
done < debian/files
93+
fi
94+
"""
95+
}
96+
}
97+
}
98+
}
99+
}
100+
}
101+
parallel branches
102+
103+
if (!currentBuild.result || currentBuild.result == 'SUCCESS') {
104+
build job: 'MultiFlexi-publish',
105+
wait: false,
106+
parameters: [
107+
string(name: 'UPSTREAM_JOB', value: env.JOB_NAME),
108+
string(name: 'UPSTREAM_BUILD', value: env.BUILD_NUMBER),
109+
string(name: 'REMOTE_SSH', value: 'multirepo@repo.multiflexi.eu'),
110+
string(name: 'REMOTE_REPO_DIR', value: '/srv/repo'),
111+
string(name: 'COMPONENT', value: 'main'),
112+
string(name: 'DEB_DIST', value: '')
113+
]
114+
}

0 commit comments

Comments
 (0)