企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Using Redis > 原文:[https://docs.gitlab.com/ee/ci/services/redis.html](https://docs.gitlab.com/ee/ci/services/redis.html) * [Use Redis with the Docker executor](#use-redis-with-the-docker-executor) * [Use Redis with the Shell executor](#use-redis-with-the-shell-executor) * [Example project](#example-project) # Using Redis[](#using-redis "Permalink") 由于许多应用程序都将 Redis 用作键值存储,因此最终需要它才能运行测试. 下面将指导您如何使用 GitLab Runner 的 Docker 和 Shell 执行程序执行此操作. ## Use Redis with the Docker executor[](#use-redis-with-the-docker-executor "Permalink") 如果您将[GitLab Runner](../runners/README.html)与 Docker 执行程序一起使用,则基本上已经完成了所有设置. 首先,在您的`.gitlab-ci.yml`添加: ``` services: - redis:latest ``` 然后,您需要配置您的应用程序以使用 Redis 数据库,例如: ``` Host: redis ``` 就是这样. 现在可以在您的测试框架中使用 Redis. 您还可以使用[Docker Hub](https://hub.docker.com/_/redis)上可用的任何其他 Docker 映像. 例如,要使用 Redis 2.8,服务将变为`redis:2.8` . ## Use Redis with the Shell executor[](#use-redis-with-the-shell-executor "Permalink") Redis 也可以在手动配置的服务器上使用,该服务器与 Shell 执行程序一起使用 GitLab Runner. 在您的构建机器中安装 Redis 服务器: ``` sudo apt-get install redis-server ``` 验证您可以使用`gitlab-runner`用户连接到服务器: ``` # Try connecting the Redis server sudo -u gitlab-runner -H redis-cli # Quit the session 127.0.0.1:6379> quit ``` 最后,将您的应用程序配置为使用数据库,例如: ``` Host: localhost ``` ## Example project[](#example-project "Permalink") 为了方便起见,我们使用公共可[共享的](../runners/README.html)运行程序在[GitLab.com](https://gitlab.com)上运行了[示例 Redis 项目](https://gitlab.com/gitlab-examples/redis) . 想要破解吗? 只需对其进行分叉,提交并推送您的更改. 稍后,公共跑步者将选择更改并开始工作.