fix: mobile server deploy — Jenkins crumb, APK build deps
Jenkins 트리거에 cookie+crumb 세션을 사용하고, 서버 APK 빌드 시 root npm ci를 실행하며 server-setup 스크립트와 Mobile job 설치를 보완한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,8 +57,13 @@ fi
|
|||||||
log "google-services.json 확인"
|
log "google-services.json 확인"
|
||||||
"$ROOT/scripts/ensure-android-google-services.sh"
|
"$ROOT/scripts/ensure-android-google-services.sh"
|
||||||
|
|
||||||
|
if [[ ! -d "$ROOT/node_modules/vite" ]]; then
|
||||||
|
log "npm ci (root dependencies)"
|
||||||
|
(cd "$ROOT" && npm ci --ignore-scripts 2>/dev/null || npm install)
|
||||||
|
fi
|
||||||
|
|
||||||
log "cap:sync"
|
log "cap:sync"
|
||||||
npm run cap:sync
|
(cd "$ROOT/app" && npm run build && bash ../scripts/ensure-android-google-services.sh && npx cap sync)
|
||||||
|
|
||||||
log "assembleRelease"
|
log "assembleRelease"
|
||||||
(cd "$ROOT/app/android" && ./gradlew assembleRelease --no-daemon)
|
(cd "$ROOT/app/android" && ./gradlew assembleRelease --no-daemon)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ mkdir -p "${JENKINS_HOME}/jobs/${JENKINS_JOB}"
|
|||||||
cat > "${JENKINS_HOME}/jobs/${JENKINS_JOB}/config.xml" << JENKINS_XML
|
cat > "${JENKINS_HOME}/jobs/${JENKINS_JOB}/config.xml" << JENKINS_XML
|
||||||
<?xml version='1.1' encoding='UTF-8'?>
|
<?xml version='1.1' encoding='UTF-8'?>
|
||||||
<project>
|
<project>
|
||||||
<description>GoldenChart Mobile — Capacitor Android APK</description>
|
<description>GoldenChart Mobile - Capacitor Android APK</description>
|
||||||
<keepDependencies>false</keepDependencies>
|
<keepDependencies>false</keepDependencies>
|
||||||
<properties/>
|
<properties/>
|
||||||
<scm class="hudson.plugins.git.GitSCM" plugin="git@5.0.0">
|
<scm class="hudson.plugins.git.GitSCM" plugin="git@5.0.0">
|
||||||
|
|||||||
Executable
+74
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# exdev 서버 — Phase 1 Mobile 배포 후 1회 설정 (hook·Jenkins·env·재시작)
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:${PATH:-/usr/bin:/bin}"
|
||||||
|
for prefix in "$HOME/homebrew" /opt/homebrew; do
|
||||||
|
[[ -x "$prefix/bin/brew" ]] && eval "$("$prefix/bin/brew" shellenv)"
|
||||||
|
done
|
||||||
|
|
||||||
|
WORK_TREE="${WORK_TREE:-/Users/aidev/apps/goldenChart}"
|
||||||
|
GIT_HOOK="${GIT_HOOK:-/Volumes/ADATA/git/goldenChart.git/hooks/post-receive}"
|
||||||
|
ENV_FILE="${ENV_FILE:-$WORK_TREE/.env}"
|
||||||
|
|
||||||
|
log() { echo "[server-setup-mobile] $*"; }
|
||||||
|
|
||||||
|
upsert_env() {
|
||||||
|
local key="$1" val="$2"
|
||||||
|
if [[ -f "$ENV_FILE" ]] && grep -q "^${key}=" "$ENV_FILE" 2>/dev/null; then
|
||||||
|
sed -i '' "s|^${key}=.*|${key}=${val}|" "$ENV_FILE"
|
||||||
|
else
|
||||||
|
echo "${key}=${val}" >> "$ENV_FILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
log "post-receive hook 업데이트"
|
||||||
|
cp "$WORK_TREE/scripts/post-receive" "$GIT_HOOK"
|
||||||
|
chmod +x "$GIT_HOOK"
|
||||||
|
|
||||||
|
log "Mobile Jenkins job 설치"
|
||||||
|
chmod +x "$WORK_TREE/scripts/"*.sh
|
||||||
|
"$WORK_TREE/scripts/server-install-mobile-jenkins.sh"
|
||||||
|
MOBILE_JOB="${JENKINS_HOME:-$HOME/.jenkins}/jobs/goldenChart-Mobile-Pipeline"
|
||||||
|
mkdir -p "$MOBILE_JOB/builds"
|
||||||
|
echo 1 > "$MOBILE_JOB/nextBuildNumber"
|
||||||
|
|
||||||
|
log ".env Mobile Jenkins 설정"
|
||||||
|
DESKTOP_USER="$(grep '^GC_DESKTOP_JENKINS_USER=' "$ENV_FILE" | cut -d= -f2- || true)"
|
||||||
|
DESKTOP_TOKEN="$(grep '^GC_DESKTOP_JENKINS_TOKEN=' "$ENV_FILE" | cut -d= -f2- || true)"
|
||||||
|
|
||||||
|
upsert_env GC_MOBILE_JENKINS_ENABLED true
|
||||||
|
upsert_env GC_MOBILE_JENKINS_URL http://host.docker.internal:8090
|
||||||
|
upsert_env GC_MOBILE_JENKINS_JOB goldenChart-Mobile-Pipeline
|
||||||
|
upsert_env GC_MOBILE_JENKINS_TRIGGER_TOKEN goldenchart-mobile-build
|
||||||
|
[[ -n "$DESKTOP_USER" ]] && upsert_env GC_MOBILE_JENKINS_USER "$DESKTOP_USER"
|
||||||
|
[[ -n "$DESKTOP_TOKEN" ]] && upsert_env GC_MOBILE_JENKINS_TOKEN "$DESKTOP_TOKEN"
|
||||||
|
|
||||||
|
if ! grep -q '^GC_MOBILE_APP_IOS_TESTFLIGHT_URL=' "$ENV_FILE" 2>/dev/null; then
|
||||||
|
echo '# TestFlight 초대 URL — App Store Connect에서 발급 후 설정' >> "$ENV_FILE"
|
||||||
|
echo 'GC_MOBILE_APP_IOS_TESTFLIGHT_URL=' >> "$ENV_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Docker backend·frontend 재빌드"
|
||||||
|
cd "$WORK_TREE"
|
||||||
|
docker compose up -d --build backend frontend
|
||||||
|
|
||||||
|
log "Mobile Jenkins 빌드 트리거"
|
||||||
|
export GC_MOBILE_JENKINS_URL=http://127.0.0.1:8090
|
||||||
|
export GC_MOBILE_JENKINS_USER="${DESKTOP_USER:-}"
|
||||||
|
export GC_MOBILE_JENKINS_TOKEN="${DESKTOP_TOKEN:-}"
|
||||||
|
"$WORK_TREE/scripts/trigger-mobile-jenkins-build.sh" || log "[WARN] Mobile Jenkins 트리거 실패"
|
||||||
|
|
||||||
|
if command -v pod >/dev/null 2>&1 && [[ -f "$WORK_TREE/app/ios/App/Podfile" ]]; then
|
||||||
|
log "iOS pod install"
|
||||||
|
(cd "$WORK_TREE/app/ios/App" && pod install) || log "[WARN] pod install 실패"
|
||||||
|
else
|
||||||
|
log "CocoaPods 없음 — iOS 빌드는 brew install cocoapods 후 pod install"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "API 확인"
|
||||||
|
sleep 4
|
||||||
|
curl -fsSL http://127.0.0.1:8080/api/mobile-app/info 2>/dev/null | python3 -m json.tool 2>/dev/null || \
|
||||||
|
curl -fsSL http://exdev.co.kr/api/mobile-app/info | python3 -m json.tool 2>/dev/null || true
|
||||||
|
|
||||||
|
log "완료"
|
||||||
@@ -13,21 +13,23 @@ log() { echo "$(date '+%Y-%m-%d %H:%M:%S') $LOG_TAG $*"; }
|
|||||||
|
|
||||||
JENKINS_URL="${JENKINS_URL%/}"
|
JENKINS_URL="${JENKINS_URL%/}"
|
||||||
JOB_API="${JENKINS_URL}/job/${JENKINS_JOB// /%20}"
|
JOB_API="${JENKINS_URL}/job/${JENKINS_JOB// /%20}"
|
||||||
|
COOKIE_JAR="$(mktemp)"
|
||||||
|
trap 'rm -f "$COOKIE_JAR"' EXIT
|
||||||
|
|
||||||
curl_get() {
|
curl_get() {
|
||||||
|
local auth=()
|
||||||
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
||||||
curl -sf -u "${JENKINS_USER}:${JENKINS_TOKEN}" "$@"
|
auth=(-u "${JENKINS_USER}:${JENKINS_TOKEN}")
|
||||||
else
|
|
||||||
curl -sf "$@"
|
|
||||||
fi
|
fi
|
||||||
|
curl -sf "${auth[@]}" -c "$COOKIE_JAR" -b "$COOKIE_JAR" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_post() {
|
curl_post() {
|
||||||
|
local auth=()
|
||||||
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
||||||
curl -sf -X POST -u "${JENKINS_USER}:${JENKINS_TOKEN}" "$@"
|
auth=(-u "${JENKINS_USER}:${JENKINS_TOKEN}")
|
||||||
else
|
|
||||||
curl -sf -X POST "$@"
|
|
||||||
fi
|
fi
|
||||||
|
curl -sf "${auth[@]}" -c "$COOKIE_JAR" -b "$COOKIE_JAR" -X POST "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
log "Jenkins desktop build — $JENKINS_JOB @ $JENKINS_URL"
|
log "Jenkins desktop build — $JENKINS_JOB @ $JENKINS_URL"
|
||||||
|
|||||||
@@ -13,21 +13,23 @@ log() { echo "$(date '+%Y-%m-%d %H:%M:%S') $LOG_TAG $*"; }
|
|||||||
|
|
||||||
JENKINS_URL="${JENKINS_URL%/}"
|
JENKINS_URL="${JENKINS_URL%/}"
|
||||||
JOB_API="${JENKINS_URL}/job/${JENKINS_JOB// /%20}"
|
JOB_API="${JENKINS_URL}/job/${JENKINS_JOB// /%20}"
|
||||||
|
COOKIE_JAR="$(mktemp)"
|
||||||
|
trap 'rm -f "$COOKIE_JAR"' EXIT
|
||||||
|
|
||||||
curl_get() {
|
curl_get() {
|
||||||
|
local auth=()
|
||||||
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
||||||
curl -sf -u "${JENKINS_USER}:${JENKINS_TOKEN}" "$@"
|
auth=(-u "${JENKINS_USER}:${JENKINS_TOKEN}")
|
||||||
else
|
|
||||||
curl -sf "$@"
|
|
||||||
fi
|
fi
|
||||||
|
curl -sf "${auth[@]}" -c "$COOKIE_JAR" -b "$COOKIE_JAR" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
curl_post() {
|
curl_post() {
|
||||||
|
local auth=()
|
||||||
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
if [[ -n "$JENKINS_USER" && -n "$JENKINS_TOKEN" ]]; then
|
||||||
curl -sf -X POST -u "${JENKINS_USER}:${JENKINS_TOKEN}" "$@"
|
auth=(-u "${JENKINS_USER}:${JENKINS_TOKEN}")
|
||||||
else
|
|
||||||
curl -sf -X POST "$@"
|
|
||||||
fi
|
fi
|
||||||
|
curl -sf "${auth[@]}" -c "$COOKIE_JAR" -b "$COOKIE_JAR" -X POST "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
log "Jenkins mobile build — $JENKINS_JOB @ $JENKINS_URL"
|
log "Jenkins mobile build — $JENKINS_JOB @ $JENKINS_URL"
|
||||||
|
|||||||
Reference in New Issue
Block a user