I want to establish a gitlab test stage that uses a gitlab service postgres database. The problem is, that everytime I try to access the database via a script call in the pipeline I get the following error:
psql: error: could not connect to server: Connection refused
Is the server running on host "postgres" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
yaml looks the following
image: some_image:latest
stages:
- test
tests:
image: node:latest
stage: test
services:
- postgres:latest
before_script:
- apt-get update && apt-get install -y postgresql-client libpq-dev
# access database script from another repo here through git clone
- psql -U postgres -h postgres < ./create-database.sql
script:
- npm install
- npm run tests
only:
- master
Am I missing something - is the database maybe not created and I am calling to soon?
VARIABLESdocs.gitlab.com/ee/ci/services/postgres.html