【发布时间】:2022-01-05 14:32:27
【问题描述】:
我正在尝试让谷歌数据存储模拟器作为 CI 的一部分运行。我在.gitlab-ci.yml 中添加了services 部分,但出现错误。
这是完整的 YAML 配置:
image: python:3.9-slim
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
variables:
DATASTORE_DATASET: project-007
DATASTORE_EMULATOR_HOST: google-cloud-sdk:8081
DATASTORE_EMULATOR_HOST_PATH: google-cloud-sdk:8081/datastore
DATASTORE_HOST: http://google-cloud-sdk:8081
DATASTORE_PROJECT_ID: project-007
before_script:
- apt-get update && apt-get install -y ffmpeg make
- python --version # Print out python version for debugging
- cd backend
- python -m pip install -r dev-requirements.txt
test:
services:
- name: google/cloud-sdk:latest
command: ["gcloud", "beta", "emulators", "datastore", "start", "--host-port", "0.0.0.0:8080"]
variables:
CLOUDSDK_CORE_PROJECT: project-007
script:
- make test
我在 CI 日志中看到的错误是:
*** WARNING: Service runner--azerasq-project-26594908-concurrent-0-aababf5d82e87691-google__cloud-sdk-0 probably didn't start properly.
Health check error:
service "runner--azerasq-project-26594908-concurrent-0-aababf5d82e87691-google__cloud-sdk-0-wait-for-service" health check: exit code 1
Health check container logs:
2021-11-25T15:49:31.057994970Z FATAL: No HOST or PORT found
Service container logs:
2021-11-25T15:49:30.783697828Z Executing: /usr/lib/google-cloud-sdk/platform/cloud-datastore-emulator/cloud_datastore_emulator create --project_id=gitlab-ci-plan-free-5-6ef84d /root/.config/gcloud/emulators/datastore
*********
任何想法如何解决这个问题或在 gitlab CI 中运行数据存储模拟器的更好方法? 谢谢!
【问题讨论】:
标签: gitlab google-cloud-datastore google-cloud-sdk