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} '