Skip to content

Commit

Permalink
Jenkinsfile now store its artifacts correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Oct 22, 2024
1 parent bb50def commit e6681be
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 142 deletions.
119 changes: 51 additions & 68 deletions Test/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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 = ''
Expand All @@ -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'
}
}
}
}
}

104 changes: 104 additions & 0 deletions Test/Jenkinsfile-arch
Original file line number Diff line number Diff line change
@@ -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'
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion Test/Jenkinsfile-external
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
73 changes: 0 additions & 73 deletions Test/Jenkinsfile-noarch

This file was deleted.

Loading

0 comments on commit e6681be

Please sign in to comment.