fix: replace emailext with mail step for reliability

main
ldl 4 months ago
parent 0b7ec659c9
commit bc367be8b9

62
Jenkinsfile vendored

@ -938,11 +938,9 @@ pipeline {
for /f %%i in ('powershell -NoLogo -NoProfile -Command "[Console]::Out.Write([uri]::EscapeDataString($env:EDUCODER_USER))"') do set USER_ENC=%%i
for /f %%i in ('powershell -NoLogo -NoProfile -Command "[Console]::Out.Write([uri]::EscapeDataString($env:EDUCODER_PASS))"') do set PASS_ENC=%%i
set "VERSION_TAG=1-0-0-%BUILD_NUMBER%"
set "RELEASE_DIR=%WORKSPACE%\release-temp"
REM 准备 artifacts 目录(保证只有本次制品)
if exist artifacts rmdir /S /Q artifacts
mkdir artifacts
REM 创建 artifacts 目录
if not exist artifacts mkdir artifacts
echo 复制制品到 artifacts 目录...
if exist target\slms-cli.jar copy /Y target\slms-cli.jar artifacts\slms-cli-!VERSION_TAG!.jar >nul
@ -950,21 +948,9 @@ pipeline {
if exist target\slms-gui.exe copy /Y target\slms-gui.exe artifacts\slms-gui-!VERSION_TAG!.exe >nul
if exist target\slms-gui-installer.msi copy /Y target\slms-gui-installer.msi artifacts\slms-gui-installer-!VERSION_TAG!.msi >nul
if exist target\slms-gui.zip copy /Y target\slms-gui.zip artifacts\slms-gui-!VERSION_TAG!.zip >nul
if exist target\slms-web.war (
copy /Y target\slms-web.war artifacts\slms-web-!VERSION_TAG!.war >nul
) else if exist target\slms-web.jar (
copy /Y target\slms-web.jar artifacts\slms-web-!VERSION_TAG!.jar >nul
)
if exist android\build\outputs\apk\debug\slms-debug.apk (
copy /Y android\build\outputs\apk\debug\slms-debug.apk artifacts\slms-debug-!VERSION_TAG!.apk >nul
) else if exist android\build\outputs\apk\debug\SLMS-debug.apk (
copy /Y android\build\outputs\apk\debug\SLMS-debug.apk artifacts\slms-debug-!VERSION_TAG!.apk >nul
)
if exist target\library.db (
copy /Y target\library.db artifacts\library-!VERSION_TAG!.db >nul
) else if exist library.db (
copy /Y library.db artifacts\library-!VERSION_TAG!.db >nul
)
if exist target\slms-web.war copy /Y target\slms-web.war artifacts\slms-web-!VERSION_TAG!.war >nul
if exist android\build\outputs\apk\debug\slms-debug.apk copy /Y android\build\outputs\apk\debug\slms-debug.apk artifacts\slms-debug-!VERSION_TAG!.apk >nul
if exist target\library.db copy /Y target\library.db artifacts\library-!VERSION_TAG!.db >nul
if exist target\run-gui.bat copy /Y target\run-gui.bat artifacts\run-gui-!VERSION_TAG!.bat >nul
if exist target\README-GUI.txt copy /Y target\README-GUI.txt artifacts\README-GUI.txt >nul
if exist target\README-GUI-EXE.txt copy /Y target\README-GUI-EXE.txt artifacts\README-GUI-EXE.txt >nul
@ -973,28 +959,16 @@ pipeline {
if exist target\slms-gui-installer.msi copy /Y target\slms-gui-installer.msi artifacts\slms-gui-installer.msi >nul
if exist target\SLMS-v1.0.0.zip copy /Y target\SLMS-v1.0.0.zip artifacts\SLMS-v1.0.0.zip >nul
REM 创建 release 临时目录
if exist "%RELEASE_DIR%" rmdir /S /Q "%RELEASE_DIR%" 2>nul
mkdir "%RELEASE_DIR%"
xcopy /E /I /Y artifacts "%RELEASE_DIR%\artifacts" >nul
REM 进入临时目录
cd /d "%RELEASE_DIR%"
REM 初始化仓库
git init
git checkout -b release
git config user.name "Jenkins CI"
git config user.email "ldl@chzu.edu.cn"
git add .
REM 创建 orphan 分支,只推送制品
git checkout --orphan release-%BUILD_NUMBER%
git rm -rf . --ignore-unmatch >nul 2>&1
git add artifacts/
git commit -m "release: 构建制品 Build #%BUILD_NUMBER%"
git remote add origin https://%USER_ENC%:%PASS_ENC%@bdgit.educoder.net/pu6zrsfoy/slms.git
echo 推送制品到头歌 release 分支...
git push --force origin release
git push https://%USER_ENC%:%PASS_ENC%@bdgit.educoder.net/pu6zrsfoy/slms.git HEAD:refs/heads/release --force
REM 切回工作目录并清理
cd /d "%WORKSPACE%"
if exist "%RELEASE_DIR%" rmdir /S /Q "%RELEASE_DIR%" 2>nul
REM 切回 main 分支
git checkout main
echo ✓ release 分支已更新制品
'''
}
@ -1080,11 +1054,9 @@ pipeline {
echo "收件人: 602924803@qq.com"
try {
emailext (
subject: emailSubject,
to: '602924803@qq.com',
body: """
SLMS 项目构建${emailStatus}
mail to: '602924803@qq.com',
subject: emailSubject,
body: """SLMS 项目构建${emailStatus}
构建编号: #${BUILD_NUMBER}
构建状态: ${emailStatus}
构建时间: ${new Date(currentBuild.startTimeInMillis)}
@ -1097,9 +1069,7 @@ SonarQube 报告: http://localhost:9000/dashboard?id=slms:slms
Release 制品: https://bdgit.educoder.net/pu6zrsfoy/slms/tree/release/SLMS
此邮件由 Jenkins 自动发送 | Build #${BUILD_NUMBER}
""",
mimeType: 'text/plain'
)
"""
echo "✓ 邮件已发送到: 602924803@qq.com"
echo "✓ 邮件主题: ${emailSubject}"
} catch (Exception e) {

Loading…
Cancel
Save