antos/Jenkinsfile
DanyLE 84e7a1a1a2
Some checks reported errors
gitea-sync/antos/pipeline/head Something is wrong with the build of this commit
improve: optimize pipeline + clean C based project before build
2024-03-10 09:11:02 +01:00

254 lines
6.2 KiB
Groovy

def build_rust_mod() {
sh '''#!/bin/bash
set -e
set -x
export RUSTUP_HOME=/opt/rust/rustup
export CARGO_HOME=/opt/rust/cargo
TARGET=
case "$arch" in
amd64)
TARGET="x86_64-unknown-linux-gnu"
;;
arm64)
TARGET="aarch64-unknown-linux-gnu"
;;
arm)
TARGET="armv7-unknown-linux-gnueabihf"
;;
*)
echo "unknown target for architecture $arch"
exit 1
;;
esac
mkdir -p build/$arch/
DESTDIR=$(realpath build/$arch/) \
PLATFORM=$arch \
RUST_TARGET=$TARGET \
RUSTUP_HOME=/opt/rust/rustup \
CARGO_HOME=/opt/rust/cargo \
make luafcgi frontend
'''
}
def build_server_and_backend() {
sh '''#!/bin/bash
set -e
set -x
TARGET=
case "$arch" in
amd64)
;;
arm64)
;;
arm)
;;
*)
echo "unknown target for architecture $arch"
exit 1
;;
esac
mkdir -p build/$arch/
DESTDIR=$(realpath build/$arch/) \
PLATFORM=$arch \
FRONTEND_IGNORE=true \
LUAFCGI_IGNORE=true \
make clean_c all
'''
}
def build_package() {
sh '''#!/bin/bash
set -e
set -x
TARGET=
case "$arch" in
amd64)
;;
arm64)
;;
arm)
;;
*)
echo "unknown target for architecture $arch"
exit 1
;;
esac
mkdir -p build/$arch/
DESTDIR=$(realpath build/$arch/) \
PLATFORM=$arch \
make deb appimg
'''
}
pipeline {
agent { node { label'master' } }
options {
// Limit build history with buildDiscarder option:
// daysToKeepStr: history is only kept up to this many days.
// numToKeepStr: only this many build logs are kept.
// artifactDaysToKeepStr: artifacts are only kept up to this many days.
// artifactNumToKeepStr: only this many builds have their artifacts kept.
buildDiscarder(logRotator(numToKeepStr: '1'))
// Enable timestamps in build log console
timestamps()
// Maximum time to run the whole pipeline before canceling it
timeout(time: 3, unit: 'HOURS')
// Use Jenkins ANSI Color Plugin for log console
ansiColor('xterm')
// Limit build concurrency to 1 per branch
disableConcurrentBuilds()
}
stages
{
stage('Prepare dependencies') {
agent {
node { label'workstation' }
}
steps {
sh'''
git submodule update --init
make clean || true
rm -rf build/* || true
'''
}
}
stage('Build Frontend (TS)') {
agent {
node { label'workstation' }
}
steps {
sh'''
mkdir -p build/frontend/
DESTDIR=$(realpath build/frontend/) make frontend
for arch in arm arm64 amd64; do
mkdir build/$arch
cp -rf build/frontend/* build/$arch/
done
rm -rf build/frontend
'''
}
}
stage('Build RUST MODULE AMD64') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'amd64'
}
build_rust_mod()
}
}
stage('Build RUST MODULE ARM64') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'arm64'
}
build_rust_mod()
}
}
stage('Build RUST MODULE ARM') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'arm'
}
build_rust_mod()
}
}
stage('Build Server + backend AMD64') {
agent {
docker {
image 'xsangle/ci-tools:latest-amd64'
reuseNode true
}
}
steps {
script {
env.arch = 'amd64'
}
build_server_and_backend()
}
}
stage('Build Server + backend ARM64') {
agent {
docker {
image 'xsangle/ci-tools:latest-arm64'
reuseNode true
}
}
steps {
script {
env.arch = 'arm64'
}
build_server_and_backend()
}
}
stage('Build Server + backend ARM') {
agent {
docker {
image 'xsangle/ci-tools:latest-arm'
reuseNode true
}
}
steps {
script {
env.arch = 'arm'
}
build_server_and_backend()
}
}
stage('Build package AMD64') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'amd64'
}
build_package()
}
}
stage('Build package ARM64') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'arm64'
}
build_package()
}
}
stage('Build package ARM') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'arm'
}
build_package()
}
}
stage('Archive') {
steps {
script {
archiveArtifacts artifacts: 'build/', fingerprint: true
}
}
}
}
}