From e6681be55cf6abb64f6025a4362b1ddf9bb609d8 Mon Sep 17 00:00:00 2001 From: CyberVitexus Date: Tue, 22 Oct 2024 10:33:01 +0200 Subject: [PATCH] Jenkinsfile now store its artifacts correctly --- Test/Jenkinsfile | 119 ++++++++++++++++---------------------- Test/Jenkinsfile-arch | 104 +++++++++++++++++++++++++++++++++ Test/Jenkinsfile-external | 2 +- Test/Jenkinsfile-noarch | 73 ----------------------- Test/Jenkinsfile-parael | 70 ++++++++++++++++++++++ 5 files changed, 226 insertions(+), 142 deletions(-) create mode 100644 Test/Jenkinsfile-arch delete mode 100644 Test/Jenkinsfile-noarch create mode 100644 Test/Jenkinsfile-parael diff --git a/Test/Jenkinsfile b/Test/Jenkinsfile index be316f3..cb2062c 100644 --- a/Test/Jenkinsfile +++ b/Test/Jenkinsfile @@ -1,13 +1,9 @@ #!groovy -// Part of https://github.com/VitexSoftware/BuildImages - -String[] architectures = [] // 'amd64', 'aarch64', 'arm', 'i386' -String[] distributions = ['debian:buster', 'debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:jammy'] +String[] distributions = ['debian:bullseye', 'debian:bookworm', 'debian:trixie', 'ubuntu:focal', 'ubuntu:jammy', 'ubuntu:noble'] String vendor = 'vitexsoftware' String distribution = '' -String architecture = '' //String distroFamily = '' String distroCodename = '' String ver = '' @@ -19,86 +15,73 @@ node() { ansiColor('xterm') { stage('SCM Checkout') { checkout scm - def control = readFile(file: env.WORKSPACE + '/debian/control') - def lines = control.readLines() - for (line in lines) { - if (line.trim()) { - def (key,value) = line.split(': ').collect { it.trim() } - if (key == 'Architecture') { - if (value == 'any') { - architectures = ['amd64', 'armhf', 'aarch64'] - } else { - architectures = [value] - } - } - } - } } } } -architectures.each { - architecture = it - - println 'Arch: ' + architecture +distributions.each { + distribution = it - distributions.each { - distribution = it + println "Dist:" + distribution - println 'Dist:' + distribution + def dist = distribution.split(':') + distroCodename = dist[1] - def dist = distribution.split(':') - // distroFamily = dist[0] - distroCodename = dist[1] + def buildImage = '' - def buildImage = '' + def artifacts = [] - node(architecture) { - ansiColor('xterm') { - stage('Checkout ' + architecture + ' ' + distribution) { - buildImage = docker.image(vendor + '/' + distribution) - sh 'git checkout debian/changelog' - def VERSION = sh( - script: 'dpkg-parsechangelog --show-field Version', + node { + ansiColor('xterm') { + stage('Checkout ' + distribution) { + checkout scm + buildImage = docker.image(vendor + '/' + distribution) + sh 'git checkout debian/changelog' + def version = sh ( + script: 'dpkg-parsechangelog --show-field Version', + returnStdout: true + ).trim() + ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename + } + stage('Build ' + distribution) { + buildImage.inside { + sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'sudo chown jenkins:jenkins ..' + sh 'debuild-pbuilder -i -us -uc -b' + 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' + artifacts = sh ( + script: "cat debian/files | awk '{print \$1}'", returnStdout: true - ).trim() - ver = VERSION + '~' + distroCodename + '~' + env.BUILD_NUMBER + ).trim().split('\n') } - stage('Build ' + architecture + ' ' + distribution) { - buildImage.inside { - sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' - sh 'sudo apt-get update --allow-releaseinfo-change' - sh 'sudo chown jenkins:jenkins ..' - sh 'debuild-pbuilder -i -us -uc -b' - 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' - } - } - - stage('Test ' + architecture + ' ' + distribution) { - buildImage.inside { - def debconf_debug = 0 //Set to "5" or "developer" to debug debconf - sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' - sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' - sh 'sudo apt-get update --allow-releaseinfo-change' - sh 'echo "INSTALATION"' - -// File insinc = new File('./InstallDebs.groovy') -// if (file.exists()) { -// evaluate(insinc) -// def installer = new InstallDebs() -// installer.aptInstall('debian/files') -// } + } - sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | grep -v dbgsym | 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 $package ; echo "test now"; done;' - stash includes: 'dist/**', name: 'dist-' + distroCodename + stage('Test ' + distribution) { + buildImage.inside { + def debconf_debug = 0 //Set to "5" or "developer" to debug debconf + sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' + sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'echo "INSTALATION"' + artifacts.each { deb_file -> + if (deb_file.endsWith('.deb')) { + sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "' + sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file + } } } - stage('Copy artifacts ' + architecture + ' ' + distribution ) { - buildImage.inside { - sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' + } + stage('Copy artifacts ' + distribution ) { + buildImage.inside { + artifacts.each { deb_file -> + println "Copying artifact: " + deb_file + archiveArtifacts artifacts: 'dist/debian/' + deb_file } + sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' } } } } } + diff --git a/Test/Jenkinsfile-arch b/Test/Jenkinsfile-arch new file mode 100644 index 0000000..9073d16 --- /dev/null +++ b/Test/Jenkinsfile-arch @@ -0,0 +1,104 @@ +#!groovy + +// Part of https://github.com/VitexSoftware/BuildImages + +String[] architectures = [] // 'amd64', 'aarch64', 'arm', 'i386' +String[] distributions = ['debian:buster', 'debian:bullseye', 'debian:bookworm', 'ubuntu:focal', 'ubuntu:jammy'] + +String vendor = 'vitexsoftware' +String distribution = '' +String architecture = '' +//String distroFamily = '' +String distroCodename = '' +String ver = '' + +properties([ + copyArtifactPermission('*') +]) +node() { + ansiColor('xterm') { + stage('SCM Checkout') { + checkout scm + def control = readFile(file: env.WORKSPACE + '/debian/control') + def lines = control.readLines() + for (line in lines) { + if (line.trim()) { + def (key,value) = line.split(': ').collect { it.trim() } + if (key == 'Architecture') { + if (value == 'any') { + architectures = ['amd64', 'armhf', 'aarch64'] + } else { + architectures = [value] + } + } + } + } + } + } +} + +architectures.each { + architecture = it + + println 'Arch: ' + architecture + + distributions.each { + distribution = it + + println 'Dist:' + distribution + + def dist = distribution.split(':') + // distroFamily = dist[0] + distroCodename = dist[1] + + def buildImage = '' + + node(architecture) { + ansiColor('xterm') { + stage('Checkout ' + architecture + ' ' + distribution) { + buildImage = docker.image(vendor + '/' + distribution) + sh 'git checkout debian/changelog' + def version = sh( + script: 'dpkg-parsechangelog --show-field version', + returnStdout: true + ).trim() + ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename + } + stage('Build ' + architecture + ' ' + distribution) { + buildImage.inside { + sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'sudo chown jenkins:jenkins ..' + sh 'debuild-pbuilder -i -us -uc -b' + 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' + } + } + + stage('Test ' + architecture + ' ' + distribution) { + buildImage.inside { + def debconf_debug = 0 //Set to "5" or "developer" to debug debconf + sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' + sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'echo "INSTALATION"' + +// File insinc = new File('./InstallDebs.groovy') +// if (file.exists()) { +// evaluate(insinc) +// def installer = new InstallDebs() +// installer.aptInstall('debian/files') +// } + + 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;' + stash includes: 'dist/**', name: 'dist-' + distroCodename + } + } + stage('Copy artifacts ' + architecture + ' ' + distribution ) { + buildImage.inside { + sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' + } + } + } + } + } +} diff --git a/Test/Jenkinsfile-external b/Test/Jenkinsfile-external index 2e937ae..11c39f7 100644 --- a/Test/Jenkinsfile-external +++ b/Test/Jenkinsfile-external @@ -84,7 +84,7 @@ architectures.each { sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' sh 'sudo apt-get update --allow-releaseinfo-change' sh 'echo "INSTALATION"' - sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | grep -v dbgsym | 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 $package ; echo "test now"; done;' + 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;' stash includes: 'dist/**', name: 'dist-' + distroCodename } } diff --git a/Test/Jenkinsfile-noarch b/Test/Jenkinsfile-noarch deleted file mode 100644 index c3720c0..0000000 --- a/Test/Jenkinsfile-noarch +++ /dev/null @@ -1,73 +0,0 @@ -#!groovy - -String[] distributions = ['debian:bullseye', 'debian:bookworm', 'debian:trixie', 'ubuntu:focal', 'ubuntu:jammy', 'ubuntu:noble'] - -String vendor = 'vitexsoftware' -String distribution = '' -//String distroFamily = '' -String distroCodename = '' -String ver = '' - -properties([ - copyArtifactPermission('*') -]) -node() { - ansiColor('xterm') { - stage('SCM Checkout') { - checkout scm - } - } -} - -distributions.each { - distribution = it - - println "Dist:" + distribution - - def dist = distribution.split(':') - // distroFamily = dist[0] - distroCodename = dist[1] - - def buildImage = '' - - node { - ansiColor('xterm') { - stage('Checkout ' + distribution) { - buildImage = docker.image(vendor + '/' + distribution) - sh 'git checkout debian/changelog' - def version = sh ( - script: 'dpkg-parsechangelog --show-field Version', - returnStdout: true - ).trim() - ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename - } - stage('Build ' + distribution) { - buildImage.inside { - sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' - sh 'sudo apt-get update --allow-releaseinfo-change' - sh 'sudo chown jenkins:jenkins ..' - sh 'debuild-pbuilder -i -us -uc -b' - 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' - } - } - - stage('Package installation Test ' + distribution) { - buildImage.inside { - def debconf_debug = 0 //Set to "5" or "developer" to debug debconf - sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' - sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' - sh 'sudo apt-get update --allow-releaseinfo-change' - sh 'echo "INSTALATION"' - sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | 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 $package ; done;' - stash includes: 'dist/**', name: 'dist-' + distroCodename - } - } - stage('Copy artifacts ' + distribution ) { - buildImage.inside { - sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' - } - } - } - } -} - diff --git a/Test/Jenkinsfile-parael b/Test/Jenkinsfile-parael new file mode 100644 index 0000000..c28d483 --- /dev/null +++ b/Test/Jenkinsfile-parael @@ -0,0 +1,70 @@ +#!groovy + +String[] distributions = ['debian:bullseye', 'debian:bookworm', 'debian:trixie', 'ubuntu:focal', 'ubuntu:jammy', 'ubuntu:noble'] + +String vendor = 'vitexsoftware' +String ver = '' + +properties([ + copyArtifactPermission('*') +]) +node() { + ansiColor('xterm') { + stage('SCM Checkout') { + checkout scm + } + } +} + +parallel distributions.collectEntries { distribution -> + ["Build and Test ${distribution}": { + node { + ansiColor('xterm') { + println "Dist:" + distribution + + def dist = distribution.split(':') + def distroCodename = dist[1] + + def buildImage = '' + + stage('Checkout ' + distribution) { + buildImage = docker.image(vendor + '/' + distribution) + sh 'ls -la' + sh 'if [ -d .git ]; then git status; fi' + sh 'git checkout -f' + def VERSION = sh( + script: 'dpkg-parsechangelog --show-field Version', + returnStdout: true + ).trim() + ver = VERSION + '~' + distroCodename + '~' + env.BUILD_NUMBER + } + stage('Build ' + distribution) { + buildImage.inside { + sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'sudo chown jenkins:jenkins ..' + sh 'debuild-pbuilder -i -us -uc -b' + 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' + } + } + stage('Test ' + distribution) { + buildImage.inside { + def debconf_debug = 0 // Set to "5" or "developer" to debug debconf + sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' + sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' + sh 'sudo apt-get update --allow-releaseinfo-change' + sh 'echo "INSTALATION"' + sh 'IFS="\n\b"; for package in `ls $WORKSPACE/dist/debian/ | grep .deb | 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 $package ; done;' + stash includes: 'dist/**', name: 'dist-' + distroCodename + } + } + stage('Copy artifacts ' + distribution) { + buildImage.inside { + sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' + } + } + } + } + }] +} +