From 8c877e871acb87b90854278c7901356df5841325 Mon Sep 17 00:00:00 2001 From: sophie <16087569+sophie_liang@user.noreply.gitee.com> Date: Mon, 18 May 2026 09:04:46 +0800 Subject: [PATCH] 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 --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 76bae2d1..d3351a7e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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} '