In gitlab-ci CI/CD, during my test, I created a MySQL service and I populate it. After this first configuration step, I want to start a set of test scripts, using a JDBC connection. I have no idea which ip address and port are used by gitlab-ci mysql services.
This is my gitlab-ci:
variables:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_DATABASE: ticketsDB
services:
- name: mysql:5.7
alias: ticketDBalias
script:
- apt-get update && apt-get install -y git curl libmcrypt-dev default-mysql-client
- mysql --version
- sleep 20
- mysql --protocol=tcp -u root -h mysql -e "create database ticketOnline; use ticketOnline;"
And I tried with configuration jdbc below, without any result:
url="jdbc:mysql://localhost:3306/ticketOnline?useTimezone=true&serverTimezone=UTC&requireSSL=true"
url="jdbc:mysql://ticketDBalias:3306/ticketOnline?useTimezone=true&serverTimezone=UTC&requireSSL=true"
Configuration error[Cannot connect to database [db]], took 0.0 sec
How can I solve it?