feat: add Jenkinsfile
Some checks failed
gitea-sync/antos/pipeline/head There was a failure building this commit

This commit is contained in:
DanyLE 2024-03-10 00:17:53 +01:00
parent 883fbe4190
commit 7a8fb51fd7
3 changed files with 228 additions and 6 deletions

222
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,222 @@
def build_rust_and_frontend() {
sh '''#!/bin/bash
set -e
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
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
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('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
}
}
}
}
}

View File

@ -17,7 +17,7 @@ BUILDID=$(shell git rev-parse --short HEAD)
VERSION_STR=$(VERSION)-$(BRANCH)-$(BUILDID)
PKG_NAME="AntOS_${VERSION_STR}_${PLATFORM}"
all: antos deb tar.gz appimg
all: antos tar.gz
antos: antd backend frontend
@ -110,7 +110,7 @@ else
@echo "Ignore building $@"
endif
deb: antos
deb:
-rm $(DESTDIR)/*.deb
scripts/mkdeb.sh $(VERSION_STR) $(PLATFORM) $(DESTDIR)
@ -118,7 +118,7 @@ tar.gz: antos
-rm $(DESTDIR)/$(PKG_NAME).tar.gz
cd $(DESTDIR)/ && tar cvzf $(PKG_NAME).tar.gz opt
appimg: antos
appimg:
-rm $(DESTDIR)/*.AppImage
scripts/mkappimg.sh $(PLATFORM) $(VERSION_STR) $(DESTDIR) $(ROOT_DIR)/antos-64.png

View File

@ -53,9 +53,9 @@ cat << EOF >> DEBIAN/control
Package: AntOS
Version: $TAG
Architecture: $archname
Depends: libsqlite3-0,zlib1g,libreadline8,libssl1.1,libvncclient1,libjpeg-turbo8 | libturbojpeg0
Maintainer: Dany LE <mrsang@iohub.dev>
Description: All-in-one AntOS remote web-based desktop environment
Depends: libsqlite3-0,zlib1g,libreadline8,libssl3,libvncclient1,libjpeg-turbo8 | libturbojpeg0
Maintainer: Dany LE <dany@iohub.dev>
Description: All-in-one AntOS web-based remote desktop environment
EOF
cat DEBIAN/control
cd ..