跳轉到

Jenkins Pipeline Web Image Build (BuildPSWebImage-MakeWish)

概念概覽

Pipeline 架構(多 agent)

核心知識

Pipeline 架構(多 agent)

Configure  → Jenkins master
Pull Repo  → mac agent (label: unityci), workspace: /data/csp/build-csp-web
Build Image → ps-db agent (Ubuntu), workspace: /data/csp/build-csp-web/<site>
Push ECR   → 呼叫子 job: PushImageToECR(推版號 + latest 各一次)
Restart    → gamania-EKS-agent (或 gamania-EKS-prod-agent)

Dockerfile 是在 pipeline 內 inline 生成

Build Image stage 使用 writeFile file: 'Dockerfile', text: dockerfile 動態寫出 Dockerfile,再執行 docker build。這表示 Dockerfile 不存在於 git repo,而是由 Groovy 字串插值決定內容。

版號與 latest 雙 tag

  • 每次 build 推兩個 tag:func-web-<version> + func-web-latest
  • latest tag 讓 K8s deployment 使用 imagePullPolicy: Always 時可以拿到最新版
  • 若 deployment 使用固定版號 tag,改版後需同步修改 Helm values

restartServer 旗標控制 init 是否執行

restartServer=true 才會觸發 Restart Web Server stage,包含刪 pod、等 rollout、執行 init-all.sh、修正 logs owner

經驗教訓

  • Dockerfile inline 生成讓 Groovy 變數可直接插入 FROM image 和 RUN 指令,但也讓 Dockerfile 從 git history 中消失,除錯時需看 Jenkins build log

  • 推同版號到 ECR 不會讓已跑的 pod 更新,必須搭配 rollout restart 或 imagePullPolicy: Always

常見陷阱

  • 同版號 build 時 Docker layer 全部 CACHED,若要確認 Dockerfile 修改有效,需確認 writeFile 內容確實有變

相關概念

來源 Sessions

日期 Session 貢獻摘要

| 2026-04-14 | 2915f12c-2e40-49a6-9734-a50edf42bc3a | 完整記錄 BuildPSWebImage-MakeWish pipeline 的多 agent 架構、Dockerfile inline 生成方式與 ECR push 機制。 |


本概念頁面由 Semi-Brain Wiki 系統自動維護

最後更新: 2026-04-14