We have a problem in our GitLab pipeline with the database service of our build job. We use a self hosted docker runner. We build up a database service based on a docker image that’s sitting in our project registry.
maven-build: extends: - .cache stage: build services: - name: $CI_REGISTRY/postgres-unit-test:latest alias: postgres <rest of the job> only: - /^feature.*$/ - /^bugfix.*$/ - master
(I ommited some of the configuration)
It works flawlessly as long as only one build is running. When we allow the runner to run pipelines concurrently some of the builds fail. I think the databases are started correctly but because of the same host the tests sometimes use the one database and sometimes the other causing test failures.
I tried to use a more specific alias for the different commits like this:
services: - name: $CI_REGISTRY/postgres-unit-test:latest alias: postgres.$CI_COMMIT_SHORT_SHA
But as soon as the host contains a number the tests can’t connect to the database:
Unable to obtain connection from database (jdbc:postgresql://postgres.f3c6c84b:5432/db) for user ‘user’: The connection attempt failed.
SQL State : 08001
Error Code : 0
Message : The connection attempt failed.
Is there a way to use the services with concurrently running builds? We would like to speed up our build process. Waiting every time for one build to finish is adding up pretty fast as we’re a big team.
Thanks for taking the time to read this.