Skip to content

Commit a13d15e

Browse files
committed
dev pipeline update
1 parent 5db666e commit a13d15e

1 file changed

Lines changed: 60 additions & 54 deletions

File tree

debian/Jenkinsfile

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,105 @@
11
#!groovy
22

3+
// Current version of this Pipeline https://github.com/VitexSoftware/BuildImages/blob/main/Test/Jenkinsfile-parael
34

4-
String repoUrl = 'https://github.com/raspberrypi/rpi-imager.git'
5-
String repoBranch = 'qml' // scm.userRemoteConfigs[0].branch
5+
String[] distributions = ['debian:bookworm', 'debian:trixie', 'debian:forky', 'ubuntu:jammy', 'ubuntu:noble']
66

7-
String[] architectures = ['amd64', 'aarch64', 'armhf']
8-
String[] distributions = ['debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:jammy'] // 'debian:buster'
9-
10-
String imageVendor = 'vitexsoftware'
11-
String distribution = ''
12-
String architecture = ''
13-
String distroCodename = ''
14-
String ver = ''
7+
String vendor = 'vitexsoftware'
8+
String imagePrefix = 'multiflexi-'
9+
//String distroFamily = ''
1510

1611
properties([
1712
copyArtifactPermission('*')
1813
])
1914
node() {
2015
ansiColor('xterm') {
2116
stage('SCM Checkout') {
22-
checkout([$class: 'GitSCM', branches: [[name: '*/' + repoBranch ]], extensions: [], userRemoteConfigs: [[url: repoUrl]]])
23-
def control = readFile(file: env.WORKSPACE + '/debian/control')
24-
def lines = control.readLines()
25-
for (line in lines) {
26-
if (line.trim()) {
27-
def (key,value) = line.split(': ').collect { it.trim() }
28-
if (key == 'Architecture') {
29-
if (value == 'any') {
30-
architectures = ['amd64', 'armhf', 'aarch64']
31-
} else {
32-
architectures = [value]
33-
}
34-
}
35-
}
36-
}
17+
checkout scm
3718
}
3819
}
3920
}
4021

41-
architectures.each {
42-
architecture = it
43-
44-
println 'Arch: ' + architecture
22+
def branches = [:]
23+
distributions.each { distro ->
24+
branches[distro] = {
25+
def distroName = distro
26+
println "Dist:" + distroName
4527

46-
distributions.each {
47-
distribution = it
28+
def dist = distroName.split(':')
29+
def distroCode = dist[1]
30+
def buildImage = ''
31+
def artifacts = []
32+
def buildVer = ''
4833

49-
println 'Dist:' + distribution
50-
51-
def String dist = distribution.split(':')
52-
// distroFamily = dist[0]
53-
distroCodename = dist[1]
54-
55-
def String buildImage = ''
56-
57-
node(architecture) {
34+
node {
5835
ansiColor('xterm') {
59-
stage('Checkout ' + architecture + ' ' + distribution) {
60-
buildImage = docker.image(imageVendor + '/' + distribution)
61-
sh 'cd ' + env.WORKSPACE + '; ls -la; pwd'
36+
stage('Checkout ' + distroName) {
37+
checkout scm
38+
def imageName = vendor + '/' + imagePrefix + distroCode + ':latest'
39+
buildImage = docker.image(imageName)
6240
sh 'git checkout debian/changelog'
63-
def String pkgVer = sh(
41+
def version = sh (
6442
script: 'dpkg-parsechangelog --show-field Version',
6543
returnStdout: true
6644
).trim()
67-
ver = pkgVer + '~' + distroCodename + '~' + env.BUILD_NUMBER
45+
buildVer = version + '.' + env.BUILD_NUMBER + '~' + distroCode
6846
}
69-
stage('Build ' + architecture + ' ' + distribution) {
47+
stage('Build ' + distroName) {
7048
buildImage.inside {
71-
sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"'
49+
sh 'dch -b -v ' + buildVer + ' "' + env.BUILD_TAG + '"'
7250
sh 'sudo apt-get update --allow-releaseinfo-change'
73-
// sh 'sudo apt install -y libgnutls28-dev'
7451
sh 'sudo chown jenkins:jenkins ..'
7552
sh 'debuild-pbuilder -i -us -uc -b'
7653
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')
7758
}
7859
}
7960

80-
stage('Test ' + architecture + ' ' + distribution) {
61+
stage('Test ' + distroName) {
8162
buildImage.inside {
8263
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'
64+
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz; cd $WORKSPACE'
8465
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
8566
sh 'sudo apt-get update --allow-releaseinfo-change'
8667
sh 'echo "INSTALATION"'
87-
sh 'IFS="\n\b"; for package in `cat debian/files | 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 $WORKSPACE/dist/debian/$package ; done;'
88-
stash includes: 'dist/**', name: 'dist-' + distroCodename
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+
}
74+
}
8975
}
9076
}
91-
stage('Copy artifacts ' + architecture + ' ' + distribution ) {
77+
stage('Archive artifacts ' + distroName ) {
78+
// Only run if previous stages (Build and Test) succeeded
9279
buildImage.inside {
93-
sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE'
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+
'''
9499
}
95100
}
96101
}
97102
}
98103
}
99104
}
105+
parallel branches

0 commit comments

Comments
 (0)