|
| 1 | +#!groovy |
| 2 | + |
| 3 | +// Docker images generated by https://github.com/VitexSoftware/BuildImages |
| 4 | + |
| 5 | + |
| 6 | +pipeline { |
| 7 | + agent none |
| 8 | + |
| 9 | + options { |
| 10 | + ansiColor('xterm') |
| 11 | + copyArtifactPermission('*'); |
| 12 | + //disableConcurrentBuilds() |
| 13 | + } |
| 14 | + |
| 15 | + environment { |
| 16 | + RED = '\\e[31m' |
| 17 | + GREEN = '\\e[32m' |
| 18 | + ENDCOLOR = '\\e[0m' |
| 19 | + } |
| 20 | + |
| 21 | + stages { |
| 22 | + |
| 23 | + stage('debian-buster') { |
| 24 | + agent { |
| 25 | + docker { image 'vitexsoftware/debian:buster' } |
| 26 | + } |
| 27 | + steps { |
| 28 | + dir('build/debian/package') { |
| 29 | + checkout scm |
| 30 | + buildPackage() |
| 31 | + installPackages() |
| 32 | + } |
| 33 | + stash includes: 'dist/**', name: 'dist-buster' |
| 34 | + } |
| 35 | + post { |
| 36 | + success { |
| 37 | + archiveArtifacts 'dist/debian/' |
| 38 | + copyArtifact() |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + stage('debian-bullseye') { |
| 44 | + agent { |
| 45 | + docker { image 'vitexsoftware/debian:bullseye' } |
| 46 | + } |
| 47 | + steps { |
| 48 | + dir('build/debian/package') { |
| 49 | + checkout scm |
| 50 | + buildPackage() |
| 51 | + installPackages() |
| 52 | + } |
| 53 | + stash includes: 'dist/**', name: 'dist-bullseye' |
| 54 | + } |
| 55 | + post { |
| 56 | + success { |
| 57 | + archiveArtifacts 'dist/debian/' |
| 58 | + copyArtifact() |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + stage('debian-bookworm') { |
| 64 | + agent { |
| 65 | + docker { image 'vitexsoftware/debian:bookworm' } |
| 66 | + } |
| 67 | + steps { |
| 68 | + dir('build/debian/package') { |
| 69 | + checkout scm |
| 70 | + sh 'sudo apt update' |
| 71 | + sh 'sudo apt install -y php-xml' //TODO: Remove after upstream dependency fix |
| 72 | + buildPackage() |
| 73 | + installPackages() |
| 74 | + } |
| 75 | + stash includes: 'dist/**', name: 'dist-bookworm' |
| 76 | + } |
| 77 | + post { |
| 78 | + success { |
| 79 | + archiveArtifacts 'dist/debian/' |
| 80 | + copyArtifact() |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + stage('ubuntu-focal') { |
| 86 | + agent { |
| 87 | + docker { image 'vitexsoftware/ubuntu:focal' } |
| 88 | + } |
| 89 | + steps { |
| 90 | + dir('build/debian/package') { |
| 91 | + checkout scm |
| 92 | + buildPackage() |
| 93 | + installPackages() |
| 94 | + } |
| 95 | + stash includes: 'dist/**', name: 'dist-focal' |
| 96 | + } |
| 97 | + post { |
| 98 | + success { |
| 99 | + archiveArtifacts 'dist/debian/' |
| 100 | + copyArtifact() |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + stage('ubuntu-hirsute') { |
| 106 | + agent { |
| 107 | + docker { image 'vitexsoftware/ubuntu:hirsute' } |
| 108 | + } |
| 109 | + steps { |
| 110 | + dir('build/debian/package') { |
| 111 | + checkout scm |
| 112 | + buildPackage() |
| 113 | + installPackages() |
| 114 | + } |
| 115 | + stash includes: 'dist/**', name: 'dist-hirsute' |
| 116 | + } |
| 117 | + post { |
| 118 | + success { |
| 119 | + archiveArtifacts 'dist/debian/' |
| 120 | + copyArtifact() |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +def copyArtifact(){ |
| 129 | + step ([$class: 'CopyArtifact', |
| 130 | + projectName: '${JOB_NAME}', |
| 131 | + filter: "**/*.deb", |
| 132 | + target: '/var/tmp/deb', |
| 133 | + flatten: true, |
| 134 | + selector: specific('${BUILD_NUMBER}') |
| 135 | + ]); |
| 136 | +} |
| 137 | + |
| 138 | +def buildPackage() { |
| 139 | + |
| 140 | + def DIST = sh ( |
| 141 | + script: 'lsb_release -sc', |
| 142 | + returnStdout: true |
| 143 | + ).trim() |
| 144 | + |
| 145 | + def DISTRO = sh ( |
| 146 | + script: 'lsb_release -sd', |
| 147 | + returnStdout: true |
| 148 | + ).trim() |
| 149 | + |
| 150 | + |
| 151 | + def SOURCE = sh ( |
| 152 | + script: 'dpkg-parsechangelog --show-field Source', |
| 153 | + returnStdout: true |
| 154 | + ).trim() |
| 155 | + |
| 156 | + def VERSION = sh ( |
| 157 | + script: 'dpkg-parsechangelog --show-field Version', |
| 158 | + returnStdout: true |
| 159 | + ).trim() |
| 160 | + |
| 161 | + ansiColor('vga') { |
| 162 | + echo '\033[42m\033[90mBuild debian package ' + SOURCE + ' v' + VERSION + ' for ' + DISTRO + '\033[0m' |
| 163 | + } |
| 164 | + |
| 165 | + def VER = VERSION + '~' + DIST + '~' + env.BUILD_NUMBER |
| 166 | + |
| 167 | +//Buster problem: Can't continue: dpkg-parsechangelog is not new enough(needs to be at least 1.17.0) |
| 168 | +// |
| 169 | +// debianPbuilder additionalBuildResults: '', |
| 170 | +// components: '', |
| 171 | +// distribution: DIST, |
| 172 | +// keyring: '', |
| 173 | +// mirrorSite: 'http://deb.debian.org/debian/', |
| 174 | +// pristineTarName: '' |
| 175 | + sh 'dch -b -v ' + VER + ' "' + env.BUILD_TAG + '"' |
| 176 | + sh 'sudo apt-get update' |
| 177 | + sh 'debuild-pbuilder -i -us -uc -b' |
| 178 | + 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' |
| 179 | +} |
| 180 | + |
| 181 | +def installPackages() { |
| 182 | + def DEBCONF_DEBUG=0 //Set to "5" or "developer" to debug debconf |
| 183 | + sh 'cd $WORKSPACE/dist/debian/ ; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz; cd $WORKSPACE' |
| 184 | + sh 'echo "deb [trusted=yes] file:////$WORKSPACE/dist/debian/ ./" | sudo tee /etc/apt/sources.list.d/local.list' |
| 185 | + sh 'sudo apt-get update' |
| 186 | + sh 'echo "${GREEN} INSTALATION ${ENDCOLOR}"' |
| 187 | + if(env.POSTINST){ |
| 188 | + run = 'echo "${GREEN} Testing launch of installed ${ENDCOLOR}"; ' + env.POSTINST + ';' |
| 189 | + } else { |
| 190 | + run = '' |
| 191 | + } |
| 192 | + |
| 193 | + 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;' |
| 194 | + sh run |
| 195 | +} |
0 commit comments