使用gitlab管道检查mongodb的连接
我正在为我的gitlab管道使用一个节点映像,其中我正在使用mongo服务,但我无法连接到db。请帮忙。我的gitlab管道如下所示:使用gitlab管道检查mongodb的连接,mongodb,gitlab,gitlab-ci,gitlab-ci-runner,Mongodb,Gitlab,Gitlab Ci,Gitlab Ci Runner,我正在为我的gitlab管道使用一个节点映像,其中我正在使用mongo服务,但我无法连接到db。请帮忙。我的gitlab管道如下所示: MONGO_HOSTNAME: mongo MONGO_PORT: 27017 MONGO_PASSWORD: root MONGO_USER: root MONGO_DB: distanceMatrixDB services: - mongo connect: stage: test image: mongo script
MONGO_HOSTNAME: mongo
MONGO_PORT: 27017
MONGO_PASSWORD: root
MONGO_USER: root
MONGO_DB: distanceMatrixDB
services:
- mongo
connect:
stage: test
image: mongo
script:
- mongo --version
#mongodb://[username:password@]host1[:port1]
- mongodb://${MONGO_USER}:${MONGO_PASSWORD}@${MONGO_HOSTNAME}:${MONGO_PORT}/${MONGO_DB}?authSource=admin;
输出 $mongo--版本 MongoDB外壳版本4.4.1 构建信息:{ “版本”:“4.4.1”, “gitVersion”:“ad91a93a5a31e175f5cbf8c69561e788bbc55ce1”, “openSSLVersion”:“OpenSSL 1.1.1 2018年9月11日”, “模块”:[], “分配器”:“tcmalloc”, “环境”:{ “distmod”:“ubuntu1804”, “distarch”:“x86_64”, “目标搜索”:“x86搜索64” } } $mongodb://${MONGO_USER}:${MONGO_PASSWORD}@${MONGO_HOSTNAME}:${MONGO_PORT}/${MONGO_DB}?authSource=admin;
/bin/bash:第106行:mongodb://root:root@mongo:27017/distanceMatrixDB?authSource=admin:没有这样的文件或目录您的gitlab runner是如何配置的?直到gitlab kubernetes executor的最新版本,而不是域名。我想到的另一件事——也许mongo只是在你试图访问它时才启动的。因此,您可以利用特定的超时来仅在应用程序准备就绪时运行应用程序。