From aa3e5bbaa7f4e88c3b62947ea3e857e6e2d0cd3d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 26 Oct 2024 13:48:05 +0000 Subject: [PATCH] jenkins: Group the package mastering stages together Signed-off-by: Michael Tremer --- Jenkinsfile | 229 ++++++++++++++++++++++++++-------------------------- 1 file changed, 115 insertions(+), 114 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 90b8adca2..d96eb74a2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -131,7 +131,7 @@ pipeline { /* Run the build and test suite on various distributions... */ - stage("Build on Multiple Distributions") { + stage("Run Tests on Multiple Distributions") { matrix { axes { axis { @@ -238,140 +238,141 @@ pipeline { } } - /* - Debian Packages - */ - stage("Build Debian Packages") { - matrix { - axes { - axis { - name "IMAGE" - values "debian:trixie", "debian:bookworm-backports" - } - - axis { - name "ARCH" - values "amd64", "arm64" - } - } + stage("Debian Packages") { + stages { + stage("Build Debian Packages") { + matrix { + axes { + axis { + name "IMAGE" + values "debian:trixie", "debian:bookworm-backports" + } - agent { - docker { - image "${IMAGE}" + axis { + name "ARCH" + values "amd64", "arm64" + } + } - // Run as root inside the containers to install dependencies - args "-u root" + agent { + docker { + image "${IMAGE}" - customWorkspace "${JOB_NAME}/${BUILD_ID}/${IMAGE.replace(":", "-")}/${ARCH}" - } - } + // Run as root inside the containers to install dependencies + args "-u root" - stages { - stage("Setup Build Environment") { - steps { - // Add the architecture - sh "dpkg --add-architecture ${env.ARCH}" - sh "apt-get update" - - // Install required packages - sh """ - apt-get install -y \ - build-essential \ - crossbuild-essential-${env.ARCH} \ - devscripts \ - qemu-user-static - """ + customWorkspace "${JOB_NAME}/${BUILD_ID}/${IMAGE.replace(":", "-")}/${ARCH}" + } } - } - stage("Install Build Dependencies") { - steps { - // Install all build dependencies - sh "apt-get build-dep -y -a${env.ARCH} ." - } - } + stages { + stage("Setup Build Environment") { + steps { + // Add the architecture + sh "dpkg --add-architecture ${env.ARCH}" + sh "apt-get update" + + // Install required packages + sh """ + apt-get install -y \ + build-essential \ + crossbuild-essential-${env.ARCH} \ + devscripts \ + qemu-user-static + """ + } + } - stage("Tag") { - steps { - sh "dch -m \"Jenkins Build ${BUILD_ID}\" -l .build-${BUILD_ID}." - } - } + stage("Install Build Dependencies") { + steps { + // Install all build dependencies + sh "apt-get build-dep -y -a${env.ARCH} ." + } + } - stage("Build") { - steps { - sh """ - dpkg-buildpackage \ - --host-arch ${env.ARCH} \ - --build=any - - # Move the packages - mkdir -pv uploads - mv -v ../*.deb uploads/ - """ - } - } + stage("Tag") { + steps { + sh "dch -m \"Jenkins Build ${BUILD_ID}\" -l .build-${BUILD_ID}." + } + } - stage("Upload Packages") { - steps { - archiveArtifacts artifacts: "uploads/**" - } - } + stage("Build") { + steps { + sh """ + dpkg-buildpackage \ + --host-arch ${env.ARCH} \ + --build=any + + # Move the packages + mkdir -pv uploads + mv -v ../*.deb uploads/ + """ + } + } - stage("Create Repository") { - environment { - DISTRO = "${IMAGE.replace("debian:", "").replace("-backports", "")}" - } + stage("Upload Packages") { + steps { + archiveArtifacts artifacts: "uploads/**" + } + } - steps { - // Create a repository and generate Packages - sh """ - mkdir -pv \ - dists/${DISTRO}/main/binary-${ARCH} \ - pool/${DISTRO}/main/${ARCH} - - # Copy all packages - cp -v uploads/*.deb pool/${DISTRO}/main/${ARCH} - - # Generate Packages.gz - dpkg-scanpackages pool/${DISTRO}/main/${ARCH} \ - | gzip -9 > dists/${DISTRO}/main/binary-${ARCH}/Packages.gz - """ - - // Stash the packages - stash includes: "dists/**/*, pool/**/*", - name: "${DISTRO}-${ARCH}" + stage("Create Repository") { + environment { + DISTRO = "${IMAGE.replace("debian:", "").replace("-backports", "")}" + } + + steps { + // Create a repository and generate Packages + sh """ + mkdir -pv \ + dists/${DISTRO}/main/binary-${ARCH} \ + pool/${DISTRO}/main/${ARCH} + + # Copy all packages + cp -v uploads/*.deb pool/${DISTRO}/main/${ARCH} + + # Generate Packages.gz + dpkg-scanpackages pool/${DISTRO}/main/${ARCH} \ + | gzip -9 > dists/${DISTRO}/main/binary-${ARCH}/Packages.gz + """ + + // Stash the packages + stash includes: "dists/**/*, pool/**/*", + name: "${DISTRO}-${ARCH}" + } + } } } } - } - } - stage("Update Debian Repository") { - agent { - docker { - image "debian:trixie" - - // Run as root inside the containers to install dependencies - args "-u root" + stage("Update Debian Repository") { + agent { + docker { + image "debian:trixie" - customWorkspace "${JOB_NAME}/${BUILD_ID}/update-debian-repo" - } - } + // Run as root inside the containers to install dependencies + args "-u root" - steps { - // Unstash all stashed packages from the matrix build - script { - for (distro in ["trixie", "bookworm"]) { - for (arch in ["amd64", "arm64"]) { - unstash "${distro}-${arch}" + customWorkspace "${JOB_NAME}/${BUILD_ID}/update-debian-repo" } } - } - // Upload everything again - archiveArtifacts artifacts: "dists/**/*, pool/**/*" + steps { + // Unstash all stashed packages from the matrix build + script { + for (distro in ["trixie", "bookworm"]) { + for (arch in ["amd64", "arm64"]) { + unstash "${distro}-${arch}" + } + } + } + + // Upload everything again + archiveArtifacts artifacts: "dists/**/*, pool/**/*" - // XXX This needs to be published on a mirror server somewhere + // XXX This needs to be published on a mirror server somewhere + } + } } } } -- 2.39.5