【发布时间】:2021-10-19 20:38:53
【问题描述】:
我的 gitlab ci 管道不断失败。似乎被困在这里。实际上我对 CI 的东西还是新手,所以我不知道做错了什么。任何帮助将不胜感激以下是 .gitlab-ci.yml 文件
image: python:latest
services:
- postgres:latest
variables:
POSTGRES_DB: thorprojectdb
POSTGRES_PASSWORD: $''
POSTGRES_USER: $majesty
POSTGRES_HOST_AUTH_METHOD: trust
# This folder is cached between builds
# http://docs.gitlab.com/ee/ci/yaml/README.html#cache
cache:
paths:
- ~/.cache/pip/
before_script:
- python -V
connect:
image: postgres
script:
# official way to provide password to psql: http://www.postgresql.org/docs/9.3/static/libpq-envars.html
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"
build:
stage: build
script:
- pip install -r requirements.txt
- python manage.py migrate
only:
- EC-30
在我的 settings.py 文件中,我有以下设置
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'projectdb',
'HOST': 'postgres',
'PASSWORD': ''
}
}
但是当我推送到 gitlab 时,构建过程一直失败。 - pip install -r requirements.txt 运行完美,但一旦到达 - python manage.py migrate,它就会失败。以下是我得到的错误
django.db.utils.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1
【问题讨论】: