根據Gitlab問題頁面:Share service between build stages.Gitlab-CI的設置方式如下:
each job is run in each job is run independently of the others,
including potentially running on different machines. And the services
are run locally on each runner. There’s no way for one job to access a
service on a different runner. On GitLab.com,we even recycle the
machine after each job runs so the services would all be destroyed.
@markpundsack
盡管已經存在7個月了,但該問題目前仍未解決.從MysqL獲取數據的問題也是一個問題,因為服務無法裝載卷(我不相信有任何計劃可以添加此功能),因此數據被卡在MysqL容器內.
因此,您可以通過以下兩種方式處理此問題:
>在同一工作中進行設置和測試
>創建一個已經添加了所有數據的sql docker(不好的做法,但是如果需要的話)
>在設置中創建轉儲并共享為工件,然后通過測試重新加載該數據
編輯:添加一條注釋,將expire_in組件用于工件可能是有用的,因為您不想存儲一堆數據,您可能永遠不需要.
編輯2:
經過研究后,我找到了gitlab的this.您可以執行以下操作:
services:
- MysqL
variables:
# Configure MysqL service (https://hub.docker.com/_/MysqL/)
MysqL_DATABASE: hello_world_test
MysqL_ROOT_PASSWORD: MysqL
connect:
image: MysqL
script:
- echo "SELECT 'OK';" | MysqL --user=root --password="$MysqL_ROOT_PASSWORD" --host=MysqL "$MysqL_DATABASE"
- SOME DATABASE DUMPING
artifacts:
when: on_success
paths:
- /var/lib/MysqL/