- csproj: GenerateBundlesBeforePublish 改为 GenerateBundlesBeforeBuild, 挂 BeforeTargets=Build 让 IDE F5/Rebuild 也能自动重建,开发者无需记命令 - rebuild-bundles.ps1/py: 加 CI 环境检测(CI/JENKINS_HOME/BUILD_NUMBER), CI 下强制全量重建避免 git checkout 后 mtime 不可靠;本地开发走增量检查 - rebuild-bundles.ps1: BOM 在重建模式下只警告不 fail(重建会自动剥离), 避免 form-layout.css 的 BOM 阻塞 CI 部署 - csproj: 新增独立 VerifyBundles target 供手动校验,不影响 Build/Publish - csproj: 新增 SkipBundleGeneration 属性开关,特殊场景可跳过自动重建 - deploy/jenkins-build.sh: 添加 Jenkins 构建脚本参考副本(不参与 CI 执行), 更新注释说明 target 改名后的 CI 行为
106 lines
4.4 KiB
Bash
106 lines
4.4 KiB
Bash
#!/bin/bash
|
|
# =============================================================================
|
|
# Jenkins CI 构建脚本(参考副本)
|
|
# =============================================================================
|
|
# 此文件为 Jenkins 节点上实际执行的构建脚本的参考副本。
|
|
# 实际执行以 Jenkins 节点上的脚本为准;本副本用于:
|
|
# 1. 让团队了解 CI 构建流程(大小写修正、publish、部署、重启)
|
|
# 2. 修改 CI 流程时有参考依据
|
|
# 3. 排查部署问题时可对照实际行为
|
|
#
|
|
# 注意:本文件不参与 CI 执行。修改此文件不会影响 Jenkins 构建。
|
|
# 如需修改 CI 流程,请联系运维同步修改 Jenkins 节点上的脚本。
|
|
# =============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
export DOTNET_ROOT=/usr/local/dotnet
|
|
export PATH=$PATH:$DOTNET_ROOT
|
|
export JENKINS_NODE_COOKIE=dontKillMe
|
|
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
|
export LANG=zh_CN.UTF-8
|
|
export LC_ALL=zh_CN.UTF-8
|
|
|
|
WS="$WORKSPACE"
|
|
|
|
# ============================================================
|
|
# 1. 文件名大小写修正(Linux 区分大小写)
|
|
# ============================================================
|
|
# Windows 不区分大小写,但 Linux 区分。
|
|
# 以下文件在仓库里的命名与 Linux 期望不一致,需要重命名。
|
|
echo "Step 1: Fix filename casing..."
|
|
|
|
safe_rename() {
|
|
local src="$1" dst="$2"
|
|
[[ "$src" == "$dst" ]] && return
|
|
if [[ -d "$src" ]]; then
|
|
mkdir -p "$dst"
|
|
rsync -a "$src"/ "$dst"/
|
|
rm -rf "$src"
|
|
elif [[ -f "$src" ]]; then
|
|
mkdir -p "$(dirname "$dst")"
|
|
mv -f "$src" "$dst"
|
|
fi
|
|
}
|
|
|
|
safe_rename "$WS/Framework/YLErp.Resources/Dictionary" "$WS/Framework/YLErp.Resources/dictionary"
|
|
safe_rename "$WS/YLErpDAL/Resources" "$WS/YLErpDAL/resources"
|
|
safe_rename "$WS/YLErpDAL/resources/clientEditConfig.js" "$WS/YLErpDAL/resources/clienteditconfig.js"
|
|
|
|
# ============================================================
|
|
# 2. 清理 & 发布
|
|
# ============================================================
|
|
# dotnet publish 会触发 csproj 中的 GenerateBundlesBeforeBuild target(挂在 Build 之前),
|
|
# 按 bundleconfig.json 增量重建前端 bundle 产物。
|
|
# CI 环境(JENKINS_HOME 存在)下脚本会强制全量重建,不依赖 git checkout 后的 mtime。
|
|
echo "Step 2: Clean & publish..."
|
|
|
|
rm -rf "$WS/otc" "$WS/RealTimeCalcPositionService"
|
|
|
|
publish() {
|
|
local name="$1" path="$2" output="$3"
|
|
echo " Publishing $name..."
|
|
cd "$path"
|
|
dotnet publish "${name}.csproj" -c Release -o "$output" --nologo
|
|
}
|
|
|
|
publish "YLErpWeb" "$WS/YLErpWeb" "$WS/otc"
|
|
publish "RealTimeCalcPositionService" "$WS/YLWinSer/RealTimeCalcPositionService" "$WS/RealTimeCalcPositionService"
|
|
publish "YLErp.Plugins.GuoLian" "$WS/Plugins/YLErp.Plugins.GuoLian" "$WS/otc/App_Plugin"
|
|
|
|
# ============================================================
|
|
# 3. 移除敏感文件
|
|
# ============================================================
|
|
echo "Step 3: Remove sensitive configs..."
|
|
|
|
rm -f "$WS/RealTimeCalcPositionService/appsettings"* "$WS/otc/appsettings"*
|
|
rm -f "$WS/RealTimeCalcPositionService/st"* "$WS/otc/st"*
|
|
|
|
# ============================================================
|
|
# 4. 同步 & 保留特定插件文件
|
|
# ============================================================
|
|
echo "Step 4: Sync to deploy directory..."
|
|
|
|
rsync -a "$WS/otc/" "/home/glms/YLErpWeb/"
|
|
rsync -a "$WS/RealTimeCalcPositionService/" "/home/glms/RealTimeCalcPositionService/"
|
|
|
|
# App_Docs 移到上级目录后删掉原位置
|
|
rsync -a --delete "$WS/otc/App_Docs/" "$WS/App_Docs/"
|
|
rm -rf "$WS/otc/App_Docs"
|
|
|
|
# App_Plugin 只保留 GuoLian 相关
|
|
find "$WS/otc/App_Plugin" -mindepth 1 -maxdepth 1 \
|
|
! -name "YLErp.Plugins.GuoLian.deps.json" \
|
|
! -name "YLErp.Plugins.GuoLian.dll" \
|
|
! -name "YLErp.Plugins.GuoLian.pdb" \
|
|
-exec rm -rf {} +
|
|
|
|
# ============================================================
|
|
# 5. 重启服务(延迟脱离 Jenkins 进程树)
|
|
# ============================================================
|
|
echo "Step 5: Schedule restart..."
|
|
echo "cd /home/glms/RealTimeCalcPositionService && sh server-ctl.sh restart" | at now + 1 minute
|
|
echo "cd /home/glms/YLErpWeb && sh server-ctl.sh restart" | at now + 2 minute
|
|
|
|
echo "Done."
|