logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Gitlab CI MySQL Configuration - YAML Example

Configure MySQL database for Gitlab CI pipelines using this YAML example. Includes setup for health checks and database connection.

Gitlab CI MySQL Configuration

This example demonstrates how to configure a MySQL database for your Gitlab CI pipelines. It includes a health check to ensure the database is running before proceeding with other pipeline stages.

YAML Configuration

---
stages:
  - healthcheck
  - run

services:
- mysql:5.7

variables:
  # Configure mysql service (https://hub.docker.com/_/mysql/)
  MYSQL_DATABASE: test
  MYSQL_ROOT_PASSWORD: testpassword

connect:
  image: mysql:5.7
  stage: healthcheck
  tags:
    - docker
  script:
  - echo "SELECT 'OK';" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"

post:
  image: mysql:5.7
  stage: run
  dependencies:
    - connect
  tags:
    - docker
  script:
  - echo done

Further Considerations

Remember to replace test and testpassword with your actual database name and root password. Consider adding more robust error handling and security measures for production environments.

External Resources

See Also