{{< details >}}
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
{{< /details >}}
使用极狐GitLab 作为微服务
许多应用程序需要访问 JSON API,因此应用程序测试可能也需要访问 API。以下示例展示如何使用极狐GitLab 作为微服务,使测试能够访问极狐GitLab API。
- 使用 Docker 或 Kubernetes 执行器配置一个 runner。
-
在你的
.gitlab-ci.yml
文件中添加: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
{{< alert type=”note” >}}
在极狐GitLab UI 中设置的变量不会传递给服务容器。有关更多信息,请参阅 极狐GitLab CI/CD 变量。
{{< /alert >}}
然后,在你的 .gitlab-ci.yml
文件的 script
部分中的命令可以访问 http://gitlab/api/v4
的 API。
有关 gitlab
用作 Host
的原因的更多信息,请参阅 如何将服务链接到作业。
你也可以使用 Docker Hub 上提供的任何其他 Docker 镜像。
gitlab
镜像可以接受环境变量。有关更多详细信息,请参阅 Linux 软件包文档。