antos/Jenkinsfile
DanyLE 7ce96d1c31
Some checks failed
gitea-sync/antos/pipeline/head There was a failure building this commit
fix(make): correct luasocket compiling
2024-03-10 01:39:56 +01:00

238 lines
5.7 KiB
Groovy

def build_rust_and_frontend() {
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
'''
}
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 RUST + FRONTEND AMD64') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'amd64'
}
build_rust_and_frontend()
}
}
stage('Build RUST + FRONTEND ARM64') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'arm64'
}
build_rust_and_frontend()
}
}
stage('Build RUST + FRONTEND ARM') {
agent {
node { label'workstation' }
}
steps {
script {
env.arch = 'arm'
}
build_rust_and_frontend()
}
}
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
}
}
}
}
}