GitLab Runner: 並行執行 job
此文件屬於建立 Docker 映像檔指南的一部分。請在此處查看完整指南:使用 Stackhero runner 及 Docker-in-Docker,從您的 GitLab CI/CD pipeline 高效地建立及推送 Docker 映像檔。
👋 歡迎瀏覽 Stackhero 文件!
Stackhero 為您提供易於使用的 GitLab Runner cloud 解決方案,專為高效處理您的 GitLab CI/CD 任務而設計。您可以享有以下優勢:
- 無限 CI/CD 時數:不按分鐘收費,您的 pipeline 可隨時運行。
- 多個並行任務:同時運行多個 job,加快整個 pipeline 的速度。
- 支援 Docker executor 及 Docker-in-Docker:簡化容器映像的建構及推送流程。
- 相容於 GitLab.com 及任何 自建 GitLab 實例。
- 專屬私人 VM,採用高速 NVMe/SSD 硬碟,確保 build 穩定可靠。
- 提供 🇪🇺 歐洲 及 🇺🇸 美國 區域選擇。
節省時間:您只需幾分鐘即可連接第一個 GitLab Runner,立即開始運行 pipeline!
您的方案會決定可同時執行多少個 job。同一個 stage 的 job 會一起啟動,最多可達您的並行上限。這代表多個獨立的 job 可以同時執行,最快的 job 完成後,整個 stage 就會結束,而不需等所有 job 順序完成。
範例:
stages:
- test
unit:
stage: test
image: node:22
script: npm run test:unit
integration:
stage: test
image: node:22
script: npm run test:integration
e2e:
stage: test
image: node:22
script: npm run test:e2e
如果您將並行數設為 1 或以上,unit、integration 和 e2e 這三個 job 會同時執行。
如需更多有關在 GitLab CI/CD pipeline 建構 Docker 映像檔的資訊,請參考 官方 GitLab Docker build 文件。