CI/CD pipeline troubleshooting
Services and databases
Can't connect to service
Make sure you're using $WSR_SERVICE_HOST_[alias] when referring to the service host.
For a more in-depth explanation, see our guide on connecting to services in CI/CD.
Trouble connecting to a service (e.g., a PostgreSQL database) may be caused by using the wrong kind of hostname.
Take the following example…
# ...
run-test-suite:
stage: test
services:
- name: postgres:latest
alias: my_psql_db
variables:
PG_USER: user
PG_PASS: password
PG_URI: postgresql://$PG_USER:$PG_PASS@my_psql_db:5432/some_db
script:
- psql "$PG_URI"
To fix it: instead of my_psql_db, use a Workshop-style reference like $WSR_SERVICE_HOST_my_psql_db.
# ...
run-test-suite:
stage: test
services:
- name: postgres:latest
alias: my_psql_db
variables:
PG_USER: user
PG_PASS: password
- PG_URI: postgresql://$PG_USER:$PG_PASS@my_psql_db:5432/some_db
+ PG_URI: postgresql://$PG_USER:$PG_PASS@$WSR_SERVICE_HOST_my_psql_db:5432/some_db
script:
- psql "$PG_URI"