title: gitlab-ci docker executor | how to setup mysql service?
body: <p>I'm trying to get a gitlab-ci build going, but I'm having trouble with the mysql setup portion. When I commit, the mysql script seems to run OK, but then the application build fails on connecting to the db. What am I missing here?</p>
  
  <p><strong>.gitlab-ci.yml</strong></p>
  
  <pre class="lang-yaml prettyprint-override"><code>stages:
    - prepare
    - test
  
  services:
    - mariadb
  
  variables:
    MYSQL_ROOT_PASSWORD: "password"
  
  connect:
    stage: prepare
    image: mysql
    script:
    - mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mariadb &lt; "data/db/scripts/create-db.sql"
    - mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mariadb &lt; "data/db/scripts/init-db-tables.sql"
  
  dev:
    stage: test
    image: java:opendjdk-8
    script:
      - ./gradlew assemble
      - ./gradlew check
  </code></pre>
  
  <p><strong>data source config</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>@Bean
  public DataSource dataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
  
      dataSource.setUrl("jdbc:mysql://mariadb:3306/rvep");
      dataSource.setUsername("root");
      dataSource.setPassword("password");
      dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  
      return dataSource;
  }
  </code></pre>
  
  <p><strong>build errors</strong>
  result of hibernate config not hitting db</p>
  
  <pre class="lang-java prettyprint-override"><code>io.abnd.rvep.RVEPTests &gt; contextLoads FAILED
      java.lang.IllegalStateException
          Caused by: org.springframework.beans.factory.BeanCreationException
              Caused by: org.springframework.beans.factory.BeanCreationException
                  Caused by: org.springframework.beans.BeanInstantiationException
                      Caused by: org.hibernate.HibernateException
  
  io.abnd.rvep.security.rest.TestControllerTest &gt; findAllRoleCategories FAILED
      java.lang.IllegalStateException
          Caused by: org.springframework.beans.factory.BeanCreationException
              Caused by: org.springframework.beans.factory.BeanCreationException
                  Caused by: org.springframework.beans.BeanInstantiationException
                      Caused by: org.hibernate.HibernateException
  
  io.abnd.rvep.security.rest.TestControllerTest &gt; findAllRoles FAILED
      java.lang.IllegalStateException
          Caused by: org.springframework.beans.factory.BeanCreationException
              Caused by: org.springframework.beans.factory.BeanCreationException
                  Caused by: org.springframework.beans.BeanInstantiationException
                      Caused by: org.hibernate.HibernateException
  </code></pre>