This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/rocketmq-studio by this push:
     new d14aed69d fix(deploy): stop the deployment when source extraction 
fails (#5885)
d14aed69d is described below

commit d14aed69dca95dd79834d75c5ac2af6fbf073481
Author: 健康宝 <[email protected]>
AuthorDate: Mon Oct 12 15:19:34 2026 +0800

    fix(deploy): stop the deployment when source extraction fails (#5885)
    
    `deploy/deploy.sh` runs under `set -euo pipefail` (`:2`) and `run_remote` 
is a bare `ssh "$REMOTE" "$@"` (`:40`), so the remote command's status is the 
step's status. `upload_source` chained its four remote stages with `;` and 
ended the whole string in `|| true` (`:74-76`), which makes that status 
unconditionally 0: a failed `tar xzf` was swallowed and the deploy walked on 
with a tree that `rm -rf server web deploy` had just wiped, only failing much 
later inside `docker build`. The tr [...]
    
    No automated coverage: the repository has no shell harness for `deploy/`, 
so reverting this change turns no assertion red. Verification was a manual 
replay of both the old and new remote command strings against a scratch 
directory, comparing exit statuses (0 before, tar's status after), plus `bash 
-n` on the script. All constructs used are POSIX, so a non-bash remote login 
shell still runs it.
---
 deploy/deploy.sh | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/deploy/deploy.sh b/deploy/deploy.sh
index 5cde0caf3..0020d7157 100755
--- a/deploy/deploy.sh
+++ b/deploy/deploy.sh
@@ -70,10 +70,13 @@ upload_source() {
   info "📤 传输源码到 $REMOTE:$REMOTE_PATH ..."
   run_remote "mkdir -p $REMOTE_PATH"
   scp -q "$SRC_TAR" "$REMOTE:$REMOTE_PATH/"
-  # 保留远端环境专属配置(tar 已排除,这里防 rm -rf 误删)
-  run_remote "cd $REMOTE_PATH && [ -f deploy/.env ] && cp deploy/.env 
/tmp/deploy-env-backup; \
-    rm -rf server web deploy && tar xzf $(basename "$SRC_TAR") && rm 
$(basename "$SRC_TAR"); \
-    [ -f /tmp/deploy-env-backup ] && mv /tmp/deploy-env-backup deploy/.env || 
true"
+  # 保留远端环境专属配置(tar 已排除,这里防 rm -rf 误删)。
+  # 任一步失败(备份 .env、清理、解压、恢复 .env)都必须让远端命令以非零退出:
+  # 旧写法用 `;` 分隔并以 `|| true` 结尾,tar 解压失败也被吞掉,部署会带着残缺源码继续走到
+  # docker build 才在别处报错。解压失败时仍先恢复 .env,再以原退出码终止。
+  run_remote "cd $REMOTE_PATH && { [ ! -f deploy/.env ] || cp deploy/.env 
/tmp/deploy-env-backup; } && \
+    { rm -rf server web deploy && tar xzf $(basename "$SRC_TAR") && rm 
$(basename "$SRC_TAR"); \
+      rc=\$?; { [ ! -f /tmp/deploy-env-backup ] || mv /tmp/deploy-env-backup 
deploy/.env; }; exit \$rc; }"
   run_remote 'docker network inspect rocketmq_net >/dev/null 2>&1 || docker 
network create rocketmq_net'
   log "源码就位,rocketmq_net 网络就绪"
 }

Reply via email to