Reputation: 31
This is a part of my .gitlab-ci.yml file
image: ruby:2.3.1
services:
- postgres:latest
- mysql:latest
...
variables:
MYSQL_RANDOM_ROOT_PASSWORD: "1"
...
All postgres variables
are specified as GitLab secure variables. But when the pipeline runs I get the following error:
ActiveRecord::NoDatabaseError: FATAL: role "runner" does not exist
If I set these variables through variables
section in .gitlab-ci.yml everything works just fine.
So it seems like these variables when set through GitLab secure variables are not set properly and postgres image doesn't use them.
My goal is to remove postgres db name, user and password from variables
section in .gitlab-ci.yml.
Please help, thanks in advance.
PS: I use docker executor.
Upvotes: 3
Views: 2183
Reputation: 2512
I'm not one to revive dead threads... but I spent a couple of hours on this issue myself and figure someone else might benefit... Turns out it was simple.
Gitlab-CI doesn't like a blank username, so I had to explicitly set it:
gitlab-ci.yml
services:
- postgres:latest
variables:
POSTGRES_DB: test
POSTGRES_USER: user
POSTGRES_PASSWORD: ""
config/database.yml
test:
host: postgres
user: user
database: test
Upvotes: 0