Skip to content

Commit d2ef41b

Browse files
committed
experiment: run per-distro builds in Kubernetes podTemplate instead of built-in Docker
Trial swap of the buildImage.inside{} Docker-on-built-in approach for a podTemplate/container('build') pod per distro, to validate whether this offloads builds onto the idle K8s cluster instead of bottlenecking on the single built-in node. UID/workspace ownership under the K8s plugin's shared workspace volume is unverified — this commit is the test.
1 parent f0df61c commit d2ef41b

1 file changed

Lines changed: 32 additions & 19 deletions

File tree

debian/Jenkinsfile

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,33 @@ distributions.each { distro ->
4343
def dist = distroName.split(':')
4444
def distroFamily = dist[0]
4545
def distroCode = dist[1]
46-
def buildImage = ''
4746
def artifacts = []
4847
def buildVer = ''
4948

50-
node('built-in') {
51-
ansiColor('xterm') {
52-
stage('Checkout ' + distroName) {
53-
sh 'sudo chown -R jenkins:jenkins . 2>/dev/null || true'
54-
checkout scm
55-
buildImage = docker.image(vendor + '/' + distro)
56-
}
57-
stage('Build ' + distroName) {
58-
buildImage.inside {
59-
// Git operations run inside the container to avoid index.lock conflicts
60-
// when multiple parallel branches share the same Jenkins agent node.
49+
podTemplate(
50+
containers: [
51+
containerTemplate(
52+
name: 'build',
53+
image: vendor + '/' + distro,
54+
command: 'sleep',
55+
args: 'infinity',
56+
resourceRequestCpu: '500m',
57+
resourceLimitCpu: '2',
58+
resourceRequestMemory: '768Mi',
59+
resourceLimitMemory: '3Gi',
60+
)
61+
],
62+
idleMinutes: 1,
63+
) {
64+
node(POD_LABEL) {
65+
ansiColor('xterm') {
66+
stage('Checkout ' + distroName) {
67+
container('build') {
68+
checkout scm
69+
}
70+
}
71+
stage('Build ' + distroName) {
72+
container('build') {
6173
sh 'git checkout debian/changelog'
6274
def version = sh(
6375
script: 'dpkg-parsechangelog --show-field Version',
@@ -95,11 +107,11 @@ distributions.each { distro ->
95107
script: "cat debian/files | awk '{print \$1}'",
96108
returnStdout: true
97109
).trim().split('\n')
110+
}
98111
}
99-
}
100112

101-
stage('Test ' + distroName) {
102-
buildImage.inside {
113+
stage('Test ' + distroName) {
114+
container('build') {
103115
def debconf_debug = 0 //Set to "5" or "developer" to debug debconf
104116
sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null > Packages; gzip -9c Packages > Packages.gz; cd $WORKSPACE'
105117
sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list'
@@ -147,11 +159,11 @@ distributions.each { distro ->
147159
}
148160
sh 'sudo rm -f /etc/apt/sources.list.d/local.list'
149161

162+
}
150163
}
151-
}
152-
stage('Archive artifacts ' + distroName ) {
153-
// Only run if previous stages (Build and Test) succeeded
154-
buildImage.inside {
164+
stage('Archive artifacts ' + distroName ) {
165+
// Only run if previous stages (Build and Test) succeeded
166+
container('build') {
155167
// Archive all produced artifacts listed in debian/files
156168
artifacts.each { deb_file ->
157169
println "Archiving artifact: " + deb_file
@@ -181,6 +193,7 @@ distributions.each { distro ->
181193
}
182194
}
183195
}
196+
}
184197

185198
parallel branches
186199

0 commit comments

Comments
 (0)