gitlab-org--gitlab-foss/doc/ci/services/gitlab.md

1.5 KiB

stage group info type
Verify Runner 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 reference

Use GitLab as a microservice (FREE)

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.

  1. Configure a runner with the Docker or Kubernetes executor.

  2. 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
    

NOTE: Variables set in the GitLab UI are not passed down to the service containers. Learn more.

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.