Use GitLab as a microservice
- Tier: Free, Premium, Ultimate
- Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
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.
Configure a runner with the Docker or Kubernetes executor.
In your
.gitlab-ci.yml
add: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
Variables set in the GitLab UI are not passed down to the service containers. For more information, see GitLab CI/CD variables.
Then, commands in script
sections in your .gitlab-ci.yml
file can access the API at http://gitlab/api/v4
.
For more information about why gitlab
is used for the Host
, see
How services are linked to the job.
You can also use any other Docker image available on Docker Hub.
The gitlab
image can accept environment variables. For more details,
see the Omnibus documentation.
Docs
Edit this page to fix an error or add an improvement in a merge request.
Create an issue to suggest an improvement to this page.
Product
Create an issue if there's something you don't like about this feature.
Propose functionality by submitting a feature request.
Feature availability and product trials
View pricing to see all GitLab tiers and features, or to upgrade.
Try GitLab for free with access to all features for 30 days.
Get help
If you didn't find what you were looking for, search the docs.
If you want help with something specific and could use community support, post on the GitLab forum.
For problems setting up or using this feature (depending on your GitLab subscription).
Request support