1

My requirement is to pull the list of SQL scripts (.sql files) from a git repository which are recently committed to the repository and run them in the database (Oracle) through SQLPLUS through Jenkins or GitLab CI/CD runner. I have Gitlab as a version control. While I know we can use SQLPLUS extension in Jenkins but I am not sure how can I get the list of committed .sql files from the Gitlab repository or how can I achieve it in Gitlab CI/CD runner. Can anyone help me with a sample shell scripts which can achieve it?

I have searched it in google but could not but any definite answer.

Thank You

Sabyasachi Mitra
  • 365
  • 1
  • 4
  • 12

1 Answers1

0

I would recommend using Gitlab CI/CD runner instead of Jenkins because:

  • It will give you access to the environment of your choice through a docker image.
  • It is well integrated with GitLab.
  • You won't have to git clone your project.

This is an example of .gitlab-ci.yml to get started:

image: debian:latest

variables:
  DOCKER_DRIVER: overlay2
  DOCKER_HOST: tcp://docker:2375

services:
  - docker:dind

stages:
  - migrate

migrate:
  stage: migrate
  script:
    - find . -type f -name '*.sql'
  only:
    - master # or tags
  tags:
    - docker

I am using docker:dind service because my gitlab ci runner is a docker container, which can start docker in it's docker container (dind = docker in docker). This is not a requirement.

I would also advised of using an appropriate database migration tools. (Ex flyway for your Java, etc...)

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204