When doing a CI/CD testing, you would need to connect a external service (RDBMS, HTTP server or generic TCP server service). So you need waiting the service before running your test app.
One way to do right waiting instead of sleep for a specified time is using
$ while ! echo -e '\x04' | nc [service_host] [service_port]; do sleep 1; done;
- MySQL service on port 3306
$ while ! echo -e '\x04' | nc 127.0.0.1 3306; do sleep 1; done;
echo -e '\x04' will send an EOT (End Of Transmission) to the TCP every second to check if it's ready !