debian-mirror-gitlab/doc/ci/services/redis.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
1.9 KiB
Markdown
Raw Normal View History

2019-09-04 21:01:54 +05:30
---
2020-06-23 00:09:42 +05:30
stage: Verify
group: Runner
2021-02-22 17:27:13 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-09-04 21:01:54 +05:30
type: reference
---
2021-11-11 11:23:49 +05:30
# Using Redis **(FREE)**
2015-12-23 02:04:40 +05:30
2021-02-22 17:27:13 +05:30
As many applications depend on Redis as their key-value store, you
2015-12-23 02:04:40 +05:30
eventually need it in order for your tests to run. Below you are guided how to
do this with the Docker and Shell executors of GitLab Runner.
## Use Redis with the Docker executor
2021-09-30 23:02:18 +05:30
If you are using [GitLab Runner](../runners/index.md) with the Docker executor
2015-12-23 02:04:40 +05:30
you basically have everything set up already.
First, in your `.gitlab-ci.yml` add:
```yaml
services:
- redis:latest
```
Then you need to configure your application to use the Redis database, for
example:
```yaml
Host: redis
```
2021-02-22 17:27:13 +05:30
And that's it. Redis is now available to be used within your testing
2015-12-23 02:04:40 +05:30
framework.
2020-06-23 00:09:42 +05:30
You can also use any other Docker image available on [Docker Hub](https://hub.docker.com/_/redis).
2020-10-24 23:57:45 +05:30
For example, to use Redis 6.0 the service becomes `redis:6.0`.
2015-12-23 02:04:40 +05:30
## Use Redis with the Shell executor
Redis can also be used on manually configured servers that are using GitLab
Runner with the Shell executor.
In your build machine install the Redis server:
2020-03-13 15:44:24 +05:30
```shell
2015-12-23 02:04:40 +05:30
sudo apt-get install redis-server
```
Verify that you can connect to the server with the `gitlab-runner` user:
2020-03-13 15:44:24 +05:30
```shell
2019-02-15 15:39:39 +05:30
# Try connecting the Redis server
2015-12-23 02:04:40 +05:30
sudo -u gitlab-runner -H redis-cli
# Quit the session
127.0.0.1:6379> quit
```
Finally, configure your application to use the database, for example:
```yaml
Host: localhost
```
## Example project
2019-12-21 20:55:43 +05:30
We have set up an [Example Redis Project](https://gitlab.com/gitlab-examples/redis) for your convenience
2015-12-23 02:04:40 +05:30
that runs on [GitLab.com](https://gitlab.com) using our publicly available
2021-09-30 23:02:18 +05:30
[shared runners](../runners/index.md).
2015-12-23 02:04:40 +05:30
2020-04-08 14:13:33 +05:30
Want to hack on it? Simply fork it, commit and push your changes. Within a few
2021-02-22 17:27:13 +05:30
moments the changes are picked by a public runner and the job begins.