Files

38 lines
1.4 KiB
Bash
Raw Permalink Normal View History

#!/bin/sh
# Linux Jenkins entry; no service deployment, data cleanup or dependency installation.
set -eu
for tool in flock timeout mvn; do
command -v "$tool" >/dev/null 2>&1 || {
echo "Required CI tool missing: $tool" >&2
exit 69
}
done
for argument in "$@"; do
case "$argument" in
-T*|--threads*)
echo 'Parallel Maven reactors are disabled on the shared TEST builder.' >&2
exit 64
;;
esac
done
# All jobs run as the same builder account. Keep the inode: flock releases on close.
# A controller-side abort must not permit another build over a surviving local build.
umask 077
lock_dir="${HOME:?HOME is required}/.cache/chongchong-ci"
mkdir -p "$lock_dir"
exec 9>"$lock_dir/maven.lock"
if ! flock -n 9; then
echo 'Another local Maven build still holds the CI lock; inspect it before retrying.' >&2
exit 75
fi
# Separate budgets: this process is Maven; ci-bounded configures its test JVM.
MAVEN_OPTS='-Xms128m -Xmx768m -XX:MaxMetaspaceSize=256m -XX:MaxDirectMemorySize=128m -XX:+ExitOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dmaven.wagon.http.retryHandler.count=3'
export MAVEN_OPTS
# Local watchdog still runs if the Jenkins controller/agent connection is lost.
# Do not use --foreground: timeout must signal the forked process group too.
exec timeout --signal=TERM --kill-after=30s 45m mvn -Pci-bounded "$@"