Skip to content

Commit b22d736

Browse files
committed
dev pipeline update
1 parent 86d40cc commit b22d736

File tree

1 file changed

+74
-56
lines changed

1 file changed

+74
-56
lines changed

debian/Jenkinsfile

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

3-
String[] distributions = ['debian:bookworm', 'debian:trixie', 'ubuntu:jammy', 'ubuntu:noble']
3+
// Current version of this Pipeline https://github.com/VitexSoftware/BuildImages/blob/main/Test/Jenkinsfile-parael
4+
5+
String[] distributions = ['debian:bookworm', 'debian:trixie', 'debian:forky', 'ubuntu:jammy', 'ubuntu:noble']
46

57
String vendor = 'vitexsoftware'
6-
String distribution = ''
8+
String imagePrefix = 'multiflexi-'
79
//String distroFamily = ''
8-
String distroCodename = ''
9-
String ver = ''
1010

1111
properties([
1212
copyArtifactPermission('*')
@@ -19,69 +19,87 @@ node() {
1919
}
2020
}
2121

22-
distributions.each {
23-
distribution = it
24-
25-
println "Dist:" + distribution
26-
27-
def dist = distribution.split(':')
28-
distroCodename = dist[1]
22+
def branches = [:]
23+
distributions.each { distro ->
24+
branches[distro] = {
25+
def distroName = distro
26+
println "Dist:" + distroName
2927

30-
def buildImage = ''
28+
def dist = distroName.split(':')
29+
def distroCode = dist[1]
30+
def buildImage = ''
31+
def artifacts = []
32+
def buildVer = ''
3133

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}'",
34+
node {
35+
ansiColor('xterm') {
36+
stage('Checkout ' + distroName) {
37+
checkout scm
38+
def imageName = vendor + '/' + imagePrefix + distroCode + ':latest'
39+
buildImage = docker.image(imageName)
40+
sh 'git checkout debian/changelog'
41+
def version = sh (
42+
script: 'dpkg-parsechangelog --show-field Version',
5543
returnStdout: true
56-
).trim().split('\n')
44+
).trim()
45+
buildVer = version + '.' + env.BUILD_NUMBER + '~' + distroCode
46+
}
47+
stage('Build ' + distroName) {
48+
buildImage.inside {
49+
sh 'dch -b -v ' + buildVer + ' "' + env.BUILD_TAG + '"'
50+
sh 'sudo apt-get update --allow-releaseinfo-change'
51+
sh 'sudo chown jenkins:jenkins ..'
52+
sh 'debuild-pbuilder -i -us -uc -b'
53+
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'
54+
artifacts = sh (
55+
script: "cat debian/files | awk '{print \$1}'",
56+
returnStdout: true
57+
).trim().split('\n')
58+
}
5759
}
58-
}
5960

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
61+
stage('Test ' + distroName) {
62+
buildImage.inside {
63+
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
64+
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz; cd $WORKSPACE'
65+
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
66+
sh 'sudo apt-get update --allow-releaseinfo-change'
67+
sh 'echo "INSTALATION"'
68+
artifacts.each { deb_file ->
69+
if (deb_file.endsWith('.deb')) {
70+
def pkgName = deb_file.tokenize('/')[-1].replaceFirst(/_.*/, '')
71+
sh 'echo -e "${GREEN} installing ' + pkgName + ' on `lsb_release -sc` ${ENDCOLOR} "'
72+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install ' + pkgName + ' || sudo apt-get -y -f install'
73+
}
7174
}
7275
}
7376
}
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
77+
stage('Archive artifacts ' + distroName ) {
78+
// Only run if previous stages (Build and Test) succeeded
79+
buildImage.inside {
80+
// Archive all produced artifacts listed in debian/files
81+
artifacts.each { deb_file ->
82+
println "Archiving artifact: " + deb_file
83+
archiveArtifacts artifacts: 'dist/debian/' + deb_file
84+
}
85+
86+
// Cleanup: remove any produced files named in debian/files
87+
// Try both the dist location and any potential original locations referenced by debian/files
88+
sh '''
89+
set -e
90+
if [ -f debian/files ]; then
91+
while read -r file _; do
92+
[ -n "$file" ] || continue
93+
rm -f "dist/debian/$file" || true
94+
rm -f "../$file" || true
95+
rm -f "$WORKSPACE/$file" || true
96+
done < debian/files
97+
fi
98+
'''
8099
}
81-
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
82100
}
83101
}
84102
}
85103
}
86104
}
87-
105+
parallel branches

0 commit comments

Comments
 (0)