apiVersion: automation.cloudbees.io/v1alpha1
kind: workflow
name: MySQL service example
on: push
jobs:
test:
services:
my-service:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: examplepassword
MYSQL_DATABASE: exampledb
args: "--default-authentication-plugin=mysql_native_password"
steps:
- name: Wait for MySQL service to be ready
uses: docker://mysql:8.0
run: |
until mysqladmin ping -h 127.0.0.1 --silent; do
echo "Waiting for database connection..."
sleep 2
done
env:
MYSQL_PWD: examplepassword
- name: Run a query
uses: docker://mysql:8.0
run: |
echo "SHOW DATABASES;" | mysql -u root -h 127.0.0.1
env:
MYSQL_PWD: examplepassword
▼