Skip to content
Snippets Groups Projects
Commit 503d3644 authored by Louis Maillard's avatar Louis Maillard
Browse files

jenkins: add build pipeline for .deb artefacts

Add a Jenkinsfile for automation of building artefacts for debian, ubuntu
and following distros.
Jenkins read a build.version file to determine version to build.

We don't just run `extras/packaging/build_package.sh -a` because this
would lead to running unverified shell script from unapproved commit
outside of docker isolation, directly on jenkins server.

Change-Id: I0482aa489272952755b88efefa0674175ca88cdd
parent cd1117cc
No related branches found
No related tags found
No related merge requests found
pipeline {
agent any
triggers {
gerrit customUrl: '',
gerritProjects: [
[branches: [[compareType: 'PLAIN', pattern: 'master']],
compareType: 'PLAIN',
disableStrictForbiddenFileVerification: false,
pattern: 'dhtnet']],
triggerOnEvents: [
commentAddedContains('!build'),
patchsetCreated(excludeDrafts: true, excludeNoCodeChange: true)]
}
options {
ansiColor('xterm')
}
parameters {
string(name: 'GERRIT_REFSPEC',
defaultValue: 'refs/heads/dhtnet',
description: 'The Gerrit refspec to fetch.')
}
environment {
PKG_NAME="dhtnet"
PKG_VERSION=""
FOLDER_NAME="$PKG_NAME-$PKG_VERSION"
}
stages {
stage('SCM Checkout') {
steps {
checkout changelog: true, poll: false,
scm: [$class: 'GitSCM',
branches: [[name: 'FETCH_HEAD']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'CloneOption', noTags: true, reference: '', shallow: true],
[$class: 'WipeWorkspace']],
submoduleCfg: [],
userRemoteConfigs: [[refspec: '${GERRIT_REFSPEC}', url: 'https://${JAMI_GERRIT_URL}/dhtnet']]]
}
}
stage('Prepare build') {
steps {
script {
PKG_VERSION=sh(
script: "head -1 extras/packaging/build.version | grep -o '^[0-9\\.]\\+\$' -",
returnStdout: true
).trim()
FOLDER_NAME="$PKG_NAME-$PKG_VERSION"
}
sh """
if [ -z "$PKG_VERSION" ]; then
echo "Empty value in build.version: $PKG_VERSION"
exit 1
fi
rm -Rf "dependencies/msgpack"
rm -Rf "dependencies/opendht"
rm -Rf "dependencies/pjproject"
rm -Rf "dependencies/restinio"
git submodule update --init --recursive
"""
dir('extras/packaging') {
sh """
rm -Rf "$FOLDER_NAME"
rm -f -- *${FOLDER_NAME}.tar.gz
mkdir -p "$FOLDER_NAME"
# copy source code
cp -Rf ../../dependencies "$FOLDER_NAME/dependencies"
cp -Rf ../../include "$FOLDER_NAME/include"
cp -Rf ../../src "$FOLDER_NAME/src"
cp -Rf ../../tools "$FOLDER_NAME/tools"
cp -Rf ../../CMakeLists.txt "$FOLDER_NAME/CMakeLists.txt"
cp -Rf ../../COPYING "$FOLDER_NAME/COPYING"
cp -Rf ../../dhtnet.pc.in "$FOLDER_NAME/dhtnet.pc.in"
cp -Rf ../../README.md "$FOLDER_NAME/README.md"
# copy debian conf and create debian/ubuntu archive
cp -Rf "./gnu-linux/debian" "$FOLDER_NAME/debian"
tar -czf "deb-${FOLDER_NAME}.tar.gz" "$FOLDER_NAME"
rm -Rf "$FOLDER_NAME/debian"
"""
}
}
}
stage('Build distributions') {
parallel {
stage('Ubuntu 22.04') {
steps {
dir('extras/packaging') {
sh """
target="ubuntu-22"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
}
}
}
stage('Ubuntu 24.04') {
steps {
dir('extras/packaging') {
sh """
target="ubuntu-24"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
}
}
}
stage('Debian 12') {
steps {
dir('extras/packaging') {
sh """
target="debian-12"
mkdir -p "\$target"
docker build -t "dhtnet-builder:\$target" -f "gnu-linux/\$target.Dockerfile" --build-arg PKG_NAME="$FOLDER_NAME" .
docker run --rm \
-v "\$(pwd)/\$target/":/build/artifacts \
-e PKG_NAME="$FOLDER_NAME" "dhtnet-builder:\$target"
"""
}
}
}
}
}
}
post {
success {
dir('extras/packaging') {
archiveArtifacts artifacts: 'ubuntu-*/dhtnet_*.deb, debian-*/dhtnet_*.deb',
caseSensitive: false
}
}
}
}
0.3.0
\ No newline at end of file
......@@ -2,7 +2,7 @@
set -e
PKG_NAME=dhtnet
PKG_VERSION=0.3.0
PKG_VERSION="$(head -1 extras/packaging/build.version | grep -o '^[0-9\.]\+$' -)"
FOLDER_NAME="${PKG_NAME}-${PKG_VERSION}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment