Skip to content

Commit e815ba8

Browse files
committed
ci: update Jenkinsfile and Jenkinsfile.release to enhance build environment and install dependencies
1 parent 210e3a8 commit e815ba8

2 files changed

Lines changed: 55 additions & 17 deletions

File tree

debian/Jenkinsfile

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#!groovy
22

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

5-
String[] distributions = [
6-
'debian:bookworm',
7-
'debian:trixie',
8-
'debian:forky',
9-
'ubuntu:jammy',
10-
'ubuntu:noble'
11-
]
5+
String[] distributions = ['debian:bookworm', 'debian:trixie', 'debian:forky', 'ubuntu:jammy', 'ubuntu:noble']
126

137
String vendor = 'vitexsoftware'
148
//String distroFamily = ''
@@ -25,7 +19,6 @@ node() {
2519
}
2620

2721
def branches = [:]
28-
2922
distributions.each { distro ->
3023
branches[distro] = {
3124
def distroName = distro
@@ -53,10 +46,22 @@ distributions.each { distro ->
5346
}
5447
stage('Build ' + distroName) {
5548
buildImage.inside {
49+
// Set unique build directories for this parallel build to avoid conflicts
50+
def uniqueBuildId = env.BUILD_NUMBER + '-' + distroCode + '-' + env.EXECUTOR_NUMBER
51+
sh '''
52+
export DH_INTERNAL_BUILDDIR="/tmp/debhelper-build-''' + uniqueBuildId + '''"
53+
export TMPDIR="/tmp/build-''' + uniqueBuildId + '''"
54+
mkdir -p "$DH_INTERNAL_BUILDDIR" "$TMPDIR"
55+
'''
5656
sh 'dch -b -v ' + buildVer + ' "' + env.BUILD_TAG + '"'
5757
sh 'sudo apt-get update --allow-releaseinfo-change'
5858
sh 'sudo chown jenkins:jenkins ..'
59-
sh 'debuild-pbuilder -i -us -uc -b'
59+
sh 'sudo rm -rf debian/$(dpkg-parsechangelog --show-field Source)/ debian/.debhelper/ debian/tmp/'
60+
sh '''
61+
export DH_INTERNAL_BUILDDIR="/tmp/debhelper-build-''' + uniqueBuildId + '''"
62+
export TMPDIR="/tmp/build-''' + uniqueBuildId + '''"
63+
debuild-pbuilder -r"sudo -E" -i -us -uc -b
64+
'''
6065
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'
6166
artifacts = sh (
6267
script: "cat debian/files | awk '{print \$1}'",
@@ -72,14 +77,41 @@ distributions.each { distro ->
7277
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
7378
sh 'sudo apt-get update --allow-releaseinfo-change'
7479
sh 'echo "INSTALATION"'
75-
artifacts.each { deb_file ->
80+
81+
def installOrder = [
82+
// '',
83+
]
84+
85+
def sorted_artifacts = artifacts.toList()
86+
87+
// If installOrder is empty, install all produced packages
88+
if (installOrder.isEmpty()) {
89+
sorted_artifacts.each { deb_file ->
7690
if (deb_file.endsWith('.deb')) {
7791
def pkgName = deb_file.tokenize('/')[-1].replaceFirst(/_.*/, '')
7892
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'
93+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install ' + pkgName
94+
}
95+
}
96+
} else {
97+
// Install packages in specified order
98+
installOrder.each { pkgPrefix ->
99+
def debFile = null
100+
for (item in sorted_artifacts) {
101+
def itemStr = item.toString()
102+
if (itemStr.startsWith(pkgPrefix) && itemStr.endsWith('.deb')) {
103+
debFile = itemStr
104+
break
105+
}
106+
}
107+
if (debFile) {
108+
def pkgName = debFile.tokenize('/')[-1].replaceFirst(/_.*/, '')
109+
sh 'echo -e "${GREEN} installing ' + pkgName + ' on `lsb_release -sc` ${ENDCOLOR} "'
110+
sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install ' + pkgName
80111
}
81112
}
82113
}
114+
83115
}
84116
stage('Archive artifacts ' + distroName ) {
85117
// Only run if previous stages (Build and Test) succeeded
@@ -92,6 +124,7 @@ distributions.each { distro ->
92124

93125
// Cleanup: remove any produced files named in debian/files
94126
// Try both the dist location and any potential original locations referenced by debian/files
127+
def uniqueBuildId = env.BUILD_NUMBER + '-' + distroCode + '-' + env.EXECUTOR_NUMBER
95128
sh '''
96129
set -e
97130
if [ -f debian/files ]; then
@@ -102,19 +135,22 @@ distributions.each { distro ->
102135
rm -f "$WORKSPACE/$file" || true
103136
done < debian/files
104137
fi
138+
# Cleanup temporary build directories
139+
rm -rf "/tmp/debhelper-build-''' + uniqueBuildId + '''" || true
140+
rm -rf "/tmp/build-''' + uniqueBuildId + '''" || true
105141
'''
106142
}
107143
}
108144
}
109145
}
110146
}
111147
}
112-
148+
}
113149

114150
parallel branches
115151

116152
node {
117153
stage('Publish to Aptly') {
118-
publishDebToAptly()
154+
publishDebToAptly()
119155
}
120156
}

debian/Jenkinsfile.release

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ distributions.each { distro ->
4545
buildVer = version + '.' + env.BUILD_NUMBER + '~' + distroCode
4646
}
4747
stage('Build ' + distroName) {
48-
buildImage.inside('--ipc=host') {
48+
buildImage.inside('--ipc=host --init') {
4949
sh 'dch -b -v ' + buildVer + ' "' + env.BUILD_TAG + '"'
5050
sh 'sudo apt-get update --allow-releaseinfo-change'
51+
sh 'sudo DEBIAN_FRONTEND=noninteractive apt-get -y install pkg-php-tools || true'
5152
sh 'sudo chown -R jenkins:jenkins . ..'
5253
sh 'sudo rm -rf debian/$(dpkg-parsechangelog --show-field Source)/ debian/.debhelper/ debian/tmp/'
5354
sh 'debuild-pbuilder -r"sudo -E" -i -us -uc -b'
@@ -60,11 +61,12 @@ distributions.each { distro ->
6061
}
6162

6263
stage('Test ' + distroName) {
63-
buildImage.inside('--ipc=host') {
64+
buildImage.inside('--ipc=host --init') {
6465
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
6566
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE'
6667
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
6768
sh 'sudo apt-get update --allow-releaseinfo-change'
69+
sh 'sudo DEBIAN_FRONTEND=noninteractive apt-get -y install composer-debian multiflexi-sqlite || true'
6870
sh 'echo "INSTALATION"'
6971
artifacts.each { deb_file ->
7072
if (deb_file.endsWith('.deb')) {
@@ -76,7 +78,7 @@ distributions.each { distro ->
7678
}
7779
stage('Archive artifacts ' + distroName ) {
7880
// Only run if previous stages (Build and Test) succeeded
79-
buildImage.inside('--ipc=host') {
81+
buildImage.inside('--ipc=host --init') {
8082
// Archive all produced artifacts listed in debian/files
8183
artifacts.each { deb_file ->
8284
println "Archiving artifact: " + deb_file

0 commit comments

Comments
 (0)