Fix Deploy Test: env branch checks out its own code on test host.

Allow env in Deploy Test stage and use origin/${BRANCH_NAME} instead of hardcoded origin/test.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
sophieandCursor committed 2026-05-18 09:04:46 +08:00
1 parent eb17ca8bc2
commit 8c877e871a
1 file changed
+5 -5
Vendored
+5 -5
View File
@@ -215,13 +215,13 @@ pipeline {
stage('Deploy Test') {
when {
expression {
// test 分支部署到 test 环境 / test branch deploys to test environment
(env.BRANCH_NAME == 'test') &&
// test / env 分支均部署到 test 环境主机;代码与当前构建分支一致(不再强制 origin/test)
(env.BRANCH_NAME == 'test' || env.BRANCH_NAME == 'env') &&
(env.FRONTEND_CHANGED == 'true' || env.BACKEND_CHANGED == 'true' || env.DEPLOY_CONFIG_CHANGED == 'true')
}
}
steps {
echo "[Deploy Test] start host=${env.TEST_DEPLOY_HOST}"
echo "[Deploy Test] start branch=${env.BRANCH_NAME} host=${env.TEST_DEPLOY_HOST}"
// 使用Jenkins中的SSH_TEST_DEPLOY私钥部署到测试服务器
// Use SSH_TEST_DEPLOY credential to deploy to test server
@@ -233,8 +233,8 @@ pipeline {
cd ${TEST_DEPLOY_ROOT}
git fetch origin
git reset --hard HEAD
git checkout -B test origin/test
git reset --hard origin/test
git checkout -B ${BRANCH_NAME} origin/${BRANCH_NAME}
git reset --hard "origin/${BRANCH_NAME}"
chmod +x scripts/deploy_compose.sh scripts/healthcheck.sh
./scripts/deploy_compose.sh test "" "" ${FRONTEND_CHANGED} ${BACKEND_CHANGED} ${DEPLOY_CONFIG_CHANGED}
'