欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

gitlab ci mysql_php-Gitlab CI:在阶段之间保留MySQL数据

发布时间:2025/3/11 数据库 33 豆豆
生活随笔 收集整理的这篇文章主要介绍了 gitlab ci mysql_php-Gitlab CI:在阶段之间保留MySQL数据 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

根据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/

总结

以上是生活随笔为你收集整理的gitlab ci mysql_php-Gitlab CI:在阶段之间保留MySQL数据的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。