Gitlab-CI:跨服务通信

Gitlab-CI: Cross-service communication

我目前正在使用 Gitlab-CI 来测试基于 jboss eap 的 java 应用程序。更准确地说,我正在使用 Postman 的 newman 工具对我所有的控制器进行 运行 一些 REST API 测试。

目前,我正在使用外部 EAP 服务器执行此操作,该服务器仅在测试期间托管我的应用程序,但我想避免这种情况并使用 gitlab-ci 服务。

唯一的问题是我的服务需要一个数据库 (pgsql),我也想为此使用一个服务,这让我想到了我的主要问题; gitlab-ci 是跨服务通信吗?有什么方法可以解决这个问题 运行ning 吗?

先谢谢大家了!

这里是 GitLab 员工。

实现此目的的一种方法是使用 Docker 和 GitLab CI/CD 的附加服务概念。您可以了解更多相关信息 here

目前没有办法做到这一点。

但是,Gitlab 有一个活跃的问题来解决这个 https://gitlab.com/gitlab-org/gitlab-runner/issues/1042

一旦实现,所有服务都应该在同一个网络上,这样就可以通过服务 name/alias.

解析彼此的 IP

现在可以使用 FF_NETWORK_PER_BUILD 功能标志。您可以将以下内容添加到您的 .gitlab-ci.yaml(在所有作业或每个作业的根目录中)。

variables:
  FF_NETWORK_PER_BUILD: 1

或者在你的运行器配置中。

From the documentation:

This networking mode creates and uses a new user-defined Docker bridge network for each job. User-defined bridge networks are covered in detail in the Docker documentation.

Unlike legacy container links used in other network modes, Docker environment variables are not shared across the containers.

Docker networks might conflict with other networks on the host, including other Docker networks, if the CIDR ranges are already in use. The default Docker address pool can be configured by using default-address-pool in dockerd.

To enable this mode you must enable the FF_NETWORK_PER_BUILD feature flag.

When a job starts, a bridge network is created (similar to docker network create ). Upon creation, the service containers and the build job container are connected to this network.

Both the container running the job and the containers running the service can resolve each other’s hostnames and aliases. This functionality is provided by Docker.

The job container is resolvable by using the build alias as well, because the hostname is assigned by GitLab.

The network is removed at the end of the job.