From 7a8fb51fd7e1ce1c4c53c3df23cadd0c741fc662 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Sun, 10 Mar 2024 00:17:53 +0100 Subject: [PATCH] feat: add Jenkinsfile --- Jenkinsfile | 222 +++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 6 +- scripts/mkdeb.sh | 6 +- 3 files changed, 228 insertions(+), 6 deletions(-) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..506bcf0 --- /dev/null +++ b/Jenkinsfile @@ -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 + } + } + } + } +} diff --git a/Makefile b/Makefile index d278a91..0c06f9d 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/mkdeb.sh b/scripts/mkdeb.sh index aabe594..f2b92f1 100755 --- a/scripts/mkdeb.sh +++ b/scripts/mkdeb.sh @@ -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 -Description: All-in-one AntOS remote web-based desktop environment +Depends: libsqlite3-0,zlib1g,libreadline8,libssl3,libvncclient1,libjpeg-turbo8 | libturbojpeg0 +Maintainer: Dany LE +Description: All-in-one AntOS web-based remote desktop environment EOF cat DEBIAN/control cd ..