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

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

40 lines
1.5 KiB
Markdown
Raw Normal View History

2021-04-29 21:17:54 +05:30
---
stage: Verify
group: Runner
2022-11-25 23:54:43 +05:30
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/product/ux/technical-writing/#assignments
2021-04-29 21:17:54 +05:30
type: reference
---
2021-11-11 11:23:49 +05:30
# Use GitLab as a microservice **(FREE)**
2021-04-29 21:17:54 +05:30
Many applications need to access JSON APIs, so application tests might need access
to APIs too. The following example shows how to use GitLab as a microservice to give
tests access to the GitLab API.
2021-09-30 23:02:18 +05:30
1. Configure a [runner](../runners/index.md) with the Docker or Kubernetes executor.
2021-04-29 21:17:54 +05:30
1. In your `.gitlab-ci.yml` add:
```yaml
services:
- name: gitlab/gitlab-ce:latest
alias: gitlab
variables:
GITLAB_HTTPS: "false" # ensure that plain http works
GITLAB_ROOT_PASSWORD: "password" # to access the api with user root:password
```
2021-11-11 11:23:49 +05:30
NOTE:
Variables set in the GitLab UI are not passed down to the service containers.
2023-04-23 21:23:45 +05:30
For more information, see [GitLab CI/CD variables](../variables/index.md).
2021-06-08 01:23:25 +05:30
2022-01-26 12:08:38 +05:30
Then, commands in `script` sections in your `.gitlab-ci.yml` file can access the API at `http://gitlab/api/v4`.
2021-04-29 21:17:54 +05:30
For more information about why `gitlab` is used for the `Host`, see
[How services are linked to the job](../docker/using_docker_images.md#extended-docker-configuration-options).
You can also use any other Docker image available on [Docker Hub](https://hub.docker.com/u/gitlab).
The `gitlab` image can accept environment variables. For more details,
2021-09-30 23:02:18 +05:30
see the [Omnibus documentation](../../install/index.md).