Merge branch 'develop_sky_liyi' into 'develop_sky'

fix:增加bundle install重试脚本

See merge request StarlockTeam/app-starlock!69
This commit is contained in:
李仪 2025-05-16 09:27:12 +00:00
commit 4c544a462e
2 changed files with 48 additions and 4 deletions

View File

@ -76,8 +76,7 @@ variables:
- bundle -v || gem install bundler --source https://gems.ruby-china.com/
- ls -li
- export NEXT_VERSION="$(cat app_new.version)"
- bundle config set --local path 'vendor/bundle_android' # Android独立依赖目录
- bundle install --gemfile android/Gemfile # 去掉--quiet便于观察进度
- bash scripts/bundle_install_retry.sh android/Gemfile vendor/bundle_android
- gem pristine --all || true # 修复所有未编译的gem扩展
script:
# 输出调试信息,便于后续排查环境问题
@ -108,8 +107,7 @@ variables:
- bundle -v || gem install bundler --source https://gems.ruby-china.com/
- ls -li
- export NEXT_VERSION="$(cat app_new.version)"
- bundle config set --local path 'vendor/bundle_ios' # iOS独立依赖目录
- bundle install --gemfile ios/Gemfile # 去掉--quiet便于观察进度
- bash scripts/bundle_install_retry.sh ios/Gemfile vendor/bundle_ios
- gem pristine --all || true # 修复所有未编译的gem扩展
script:
# 输出调试信息,便于后续排查环境问题

View File

@ -0,0 +1,46 @@
#!/bin/bash
# 用法: ./scripts/bundle_install_retry.sh <gemfile_path> <bundle_path>
# 例如: ./scripts/bundle_install_retry.sh android/Gemfile vendor/bundle_android
GEMFILE_PATH="$1"
BUNDLE_PATH="$2"
if [ -z "$GEMFILE_PATH" ] || [ -z "$BUNDLE_PATH" ]; then
echo "用法: $0 <gemfile_path> <bundle_path>"
exit 1
fi
try_count=0
max_try=3
success=0
# 先用阿里云镜像
bundle config mirror.https://rubygems.org https://mirrors.aliyun.com/rubygems/
while [ $try_count -lt $max_try ]; do
echo "[INFO] 第$((try_count+1))次尝试使用阿里云镜像 bundle install..."
bundle config set --local path "$BUNDLE_PATH"
bundle install --gemfile "$GEMFILE_PATH"
if [ $? -eq 0 ]; then
echo "[SUCCESS] 使用阿里云镜像 bundle install 成功"
success=1
break
fi
try_count=$((try_count+1))
sleep 2
echo "[WARN] 阿里云镜像 bundle install 第$try_count 次失败,准备重试..."
done
if [ $success -eq 0 ]; then
echo "[ERROR] 阿里云镜像 bundle install 失败$max_try次,切换为官方源重试..."
bundle config mirror.https://rubygems.org https://rubygems.org
bundle config set --local path "$BUNDLE_PATH"
bundle install --gemfile "$GEMFILE_PATH"
if [ $? -eq 0 ]; then
echo "[SUCCESS] 官方源 bundle install 成功"
exit 0
else
echo "[FATAL] 官方源 bundle install 依然失败请检查网络或Gemfile配置。"
exit 2
fi
fi
exit 0