Skip to content

Commit e6f139d

Browse files
Vitexusclaude
andcommitted
feat: add debian/Jenkinsfile for testing repository builds
Parallel builds across bookworm/trixie/jammy/noble using vitexsoftware/<distro> images; publishes to testing repo via publishDebToAptly(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 09fd955 commit e6f139d

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

debian/Jenkinsfile

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!groovy
2+
3+
// Current version of this Pipeline https://github.com/VitexSoftware/BuildImages/blob/main/Test/Jenkinsfile-parael
4+
5+
// debian:forky disabled: Forky is still unstable/research-only.
6+
// The full Debian package ecosystem is not yet available for Forky.
7+
// Re-enable once the stack builds cleanly for Forky.
8+
String[] distributions = ['debian:bookworm', 'debian:trixie', 'ubuntu:jammy', 'ubuntu:noble']
9+
10+
String vendor = 'vitexsoftware'
11+
12+
properties([
13+
copyArtifactPermission('*'),
14+
buildBlocker(
15+
useBuildBlocker: true,
16+
blockLevel: 'GLOBAL',
17+
scanQueueFor: 'ALL',
18+
blockingJobs: 'RebulidDEBRepoByAnsible'
19+
)
20+
])
21+
node() {
22+
ansiColor('xterm') {
23+
stage('SCM Checkout') {
24+
checkout scm
25+
}
26+
}
27+
}
28+
29+
def branches = [:]
30+
distributions.each { distro ->
31+
branches[distro] = {
32+
def distroName = distro
33+
println "Dist:" + distroName
34+
35+
def dist = distroName.split(':')
36+
def distroCode = dist[1]
37+
def buildImage = ''
38+
def artifacts = []
39+
def buildVer = ''
40+
41+
node {
42+
ansiColor('xterm') {
43+
stage('Checkout ' + distroName) {
44+
checkout scm
45+
def imageName = vendor + '/' + distro
46+
buildImage = docker.image(imageName)
47+
sh 'git checkout debian/changelog'
48+
def version = sh (
49+
script: 'dpkg-parsechangelog --show-field Version',
50+
returnStdout: true
51+
).trim()
52+
buildVer = version + '.' + env.BUILD_NUMBER + '~' + distroCode
53+
}
54+
stage('Build ' + distroName) {
55+
buildImage.inside {
56+
sh 'dch -b -v ' + buildVer + ' "' + env.BUILD_TAG + '"'
57+
sh 'sudo apt-get update --allow-releaseinfo-change'
58+
sh 'sudo chown jenkins:jenkins ..'
59+
sh 'debuild-pbuilder -i -us -uc -b'
60+
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'
61+
artifacts = sh (
62+
script: "cat debian/files | awk '{print \$1}'",
63+
returnStdout: true
64+
).trim().split('\n')
65+
}
66+
}
67+
68+
stage('Test ' + distroName) {
69+
buildImage.inside {
70+
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
71+
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz; cd $WORKSPACE'
72+
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
73+
sh 'sudo apt-get update --allow-releaseinfo-change'
74+
sh 'echo "INSTALATION"'
75+
artifacts.each { deb_file ->
76+
if (deb_file.endsWith('.deb')) {
77+
def pkgName = deb_file.tokenize('/')[-1].replaceFirst(/_.*/, '')
78+
sh 'echo -e "${GREEN} installing ' + pkgName + ' on `lsb_release -sc` ${ENDCOLOR} "'
79+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install ' + pkgName + ' || sudo apt-get -y -f install'
80+
}
81+
}
82+
}
83+
}
84+
stage('Archive artifacts ' + distroName ) {
85+
buildImage.inside {
86+
artifacts.each { deb_file ->
87+
println "Archiving artifact: " + deb_file
88+
archiveArtifacts artifacts: 'dist/debian/' + deb_file
89+
}
90+
sh '''
91+
set -e
92+
if [ -f debian/files ]; then
93+
while read -r file _; do
94+
[ -n "$file" ] || continue
95+
rm -f "dist/debian/$file" || true
96+
rm -f "../$file" || true
97+
rm -f "$WORKSPACE/$file" || true
98+
done < debian/files
99+
fi
100+
'''
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}
107+
parallel branches
108+
109+
node {
110+
stage('Publish to Aptly') {
111+
publishDebToAptly()
112+
}
113+
}

0 commit comments

Comments
 (0)