Fix ffg-build.sh — battle-tested SSH flags from live build

- NC1_KEY points to /opt/mod-builds/ffg_build_rsa (accessible to claude user)
- Added -o IdentitiesOnly=yes to all SSH/rsync calls (prevents agent key conflicts)
- Added -e NC1_SSH to rsync commands for consistent key usage
- All 3 discord-rules jars now built successfully (1.20.1, 1.16.5, 1.21.1)
This commit is contained in:
Claude
2026-04-12 23:43:17 +00:00
parent 11e2d7db7d
commit 48097a9a57

View File

@@ -10,9 +10,8 @@ VERSION="${1:-}"
WORKSPACE="/opt/mod-builds/firefrost-services/services/discord-rules"
NC1_USER="ffg-builder"
NC1_HOST="216.239.104.130"
NC1_KEY="${HOME}/.ssh/ffg_build_rsa"
NC1_KEY="/opt/mod-builds/ffg_build_rsa"
NC1_WORKSPACE="/home/ffg-builder/workspaces/build-$$"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ -z "$VERSION" ]]; then
echo "[ERROR] Usage: ffg-build.sh <mc_version>"
@@ -20,31 +19,31 @@ if [[ -z "$VERSION" ]]; then
exit 1
fi
# Route decision
if [[ "$VERSION" == "1.21.1" ]]; then
echo "[ROUTING] NeoForge $VERSION — routing build to NC1 (Vineflower RAM requirement)"
# Trap: clean up NC1 workspace on exit (covers drops, errors, ctrl+c)
trap 'echo "[CLEANUP] Removing NC1 workspace..."; ssh -i "$NC1_KEY" -o StrictHostKeyChecking=no "$NC1_USER@$NC1_HOST" "rm -rf $NC1_WORKSPACE" 2>/dev/null || true' EXIT
trap 'echo "[CLEANUP] Removing NC1 workspace..."; ssh -i "$NC1_KEY" -o StrictHostKeyChecking=no -o IdentitiesOnly=yes "$NC1_USER@$NC1_HOST" "rm -rf $NC1_WORKSPACE" 2>/dev/null || true' EXIT
NC1_SSH="ssh -i $NC1_KEY -o StrictHostKeyChecking=no -o IdentitiesOnly=yes"
# Create workspace on NC1
ssh -i "$NC1_KEY" -o StrictHostKeyChecking=no "$NC1_USER@$NC1_HOST" \
ssh -i "$NC1_KEY" -o StrictHostKeyChecking=no -o IdentitiesOnly=yes "$NC1_USER@$NC1_HOST" \
"mkdir -p $NC1_WORKSPACE"
# Sync source to NC1 (exclude local build artifacts and gradle cache)
rsync -az --exclude 'build/' --exclude '.gradle/' \
rsync -az -e "$NC1_SSH" --exclude 'build/' --exclude '.gradle/' \
"$WORKSPACE/$VERSION/" \
"$NC1_USER@$NC1_HOST:$NC1_WORKSPACE/"
echo "[NC1] Running Gradle build..."
ssh -i "$NC1_KEY" -o StrictHostKeyChecking=no "$NC1_USER@$NC1_HOST" \
ssh -i "$NC1_KEY" -o StrictHostKeyChecking=no -o IdentitiesOnly=yes "$NC1_USER@$NC1_HOST" \
"cd $NC1_WORKSPACE && ./gradlew build --no-daemon"
# Retrieve only the compiled jar
mkdir -p "$WORKSPACE/$VERSION/build/libs"
rsync -az \
rsync -az -e "$NC1_SSH" \
"$NC1_USER@$NC1_HOST:$NC1_WORKSPACE/build/libs/" \
"$WORKSPACE/$VERSION/build/libs/" \
--include "*.jar" --exclude "*"