|
| 1 | +#!groovy |
| 2 | + |
| 3 | +String[] distributions = ['debian:bookworm', 'debian:trixie', 'ubuntu:jammy', 'ubuntu:noble'] |
| 4 | + |
| 5 | +String vendor = 'vitexsoftware' |
| 6 | +String distribution = '' |
| 7 | +//String distroFamily = '' |
| 8 | +String distroCodename = '' |
| 9 | +String ver = '' |
| 10 | + |
| 11 | +properties([ |
| 12 | + copyArtifactPermission('*') |
| 13 | +]) |
| 14 | +node() { |
| 15 | + ansiColor('xterm') { |
| 16 | + stage('SCM Checkout') { |
| 17 | + checkout scm |
| 18 | + } |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +distributions.each { |
| 23 | + distribution = it |
| 24 | + |
| 25 | + println "Dist:" + distribution |
| 26 | + |
| 27 | + def dist = distribution.split(':') |
| 28 | + distroCodename = dist[1] |
| 29 | + |
| 30 | + def buildImage = '' |
| 31 | + |
| 32 | + def artifacts = [] |
| 33 | + |
| 34 | + node { |
| 35 | + ansiColor('xterm') { |
| 36 | + stage('Checkout ' + distribution) { |
| 37 | + checkout scm |
| 38 | + buildImage = docker.image(vendor + '/' + distribution) |
| 39 | + sh 'git checkout debian/changelog' |
| 40 | + def version = sh ( |
| 41 | + script: 'dpkg-parsechangelog --show-field Version', |
| 42 | + returnStdout: true |
| 43 | + ).trim() |
| 44 | + ver = version + '.' + env.BUILD_NUMBER + '~' + distroCodename |
| 45 | + } |
| 46 | + stage('Build ' + distribution) { |
| 47 | + buildImage.inside { |
| 48 | + sh 'dch -b -v ' + ver + ' "' + env.BUILD_TAG + '"' |
| 49 | + sh 'sudo apt-get update --allow-releaseinfo-change' |
| 50 | + sh 'sudo chown jenkins:jenkins ..' |
| 51 | + sh 'debuild-pbuilder -i -us -uc -b' |
| 52 | + 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' |
| 53 | + artifacts = sh ( |
| 54 | + script: "cat debian/files | awk '{print \$1}'", |
| 55 | + returnStdout: true |
| 56 | + ).trim().split('\n') |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + stage('Test ' + distribution) { |
| 61 | + buildImage.inside { |
| 62 | + def debconf_debug = 0 //Set to "5" or "developer" to debug debconf |
| 63 | + sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' |
| 64 | + sh 'echo "deb [trusted=yes] file://///$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' |
| 65 | + sh 'sudo apt-get update --allow-releaseinfo-change' |
| 66 | + sh 'echo "INSTALATION"' |
| 67 | + artifacts.each { deb_file -> |
| 68 | + if (deb_file.endsWith('.deb')) { |
| 69 | + sh 'echo -e "${GREEN} installing ' + deb_file + ' on `lsb_release -sc` ${ENDCOLOR} "' |
| 70 | + sh 'sudo DEBIAN_FRONTEND=noninteractive DEBCONF_DEBUG=' + debconf_debug + ' apt-get -y install $WORKSPACE/dist/debian/' + deb_file |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + stage('Copy artifacts ' + distribution ) { |
| 76 | + buildImage.inside { |
| 77 | + artifacts.each { deb_file -> |
| 78 | + println "Copying artifact: " + deb_file |
| 79 | + archiveArtifacts artifacts: 'dist/debian/' + deb_file |
| 80 | + } |
| 81 | + sh 'mv $WORKSPACE/dist/debian/*.deb $WORKSPACE' |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | +} |
| 87 | + |
0 commit comments