fix: 修复构建脚本末尾grep导致set -e失败 #304

Merged
xiaoxia merged 1 commits from fix/build-script-grep-set-e into develop 2026-07-14 09:55:59 +08:00
Owner

问题

Build & Push Staging构建实际成功(镜像都推上去了),但脚本最后一行 docker images | grep "xiaoxia-saas.*:$VERSION" 导致整个Job失败。

根因:

  1. set -e + grep 经典陷阱:grep无匹配时返回exit 1
  2. grep模式本身也不对:docker images 输出中REPOSITORY和TAG是两列(中间空格,没有冒号),xiaoxia-saas.*:$VERSION 永远匹配不到

修复

改为两段式grep + || true 安全网,只做展示用,不影响构建结果。

## 问题 Build & Push Staging构建实际成功(镜像都推上去了),但脚本最后一行 `docker images | grep "xiaoxia-saas.*:$VERSION"` 导致整个Job失败。 根因: 1. `set -e` + `grep` 经典陷阱:grep无匹配时返回exit 1 2. grep模式本身也不对:`docker images` 输出中REPOSITORY和TAG是两列(中间空格,没有冒号),`xiaoxia-saas.*:$VERSION` 永远匹配不到 ## 修复 改为两段式grep + `|| true` 安全网,只做展示用,不影响构建结果。
xiaoxia added 1 commit 2026-07-14 09:39:49 +08:00
fix: prevent docker images grep from failing build with set -e
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Successful in 37s
CI/CD Pipeline / Frontend Lint (pull_request) Successful in 1m10s
CI/CD Pipeline / Build & Push Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Build Production Runtime Images (pull_request) Has been skipped
CI/CD Pipeline / Unit Tests (pull_request) Successful in 1m25s
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Integration Tests (pull_request) Successful in 2m1s
819d3ae23d
The last line of the build script uses grep to display built images,
but with set -e, grep returning no matches causes the entire script
to fail. This is a classic set -e footgun.

The grep pattern was also broken: docker images shows REPOSITORY and
TAG as separate columns (no ':' between them), so 'xiaoxia-saas.*:'
never matched. Changed to two-stage grep and added || true safety net.

The build and push were actually succeeding - only the final display
line was causing the failure.
xiaoxia merged commit 9ddaaf7f00 into develop 2026-07-14 09:55:59 +08:00
Sign in to join this conversation.