GitLab CI/CD Setup

You can set up Liquibase without a local installation or remote host by using GitLab CI/CD.

GitLab CI/CD is a GitLab tool that automates the process of building, testing, and deploying software changes to your repository using pipelines, which are made up of jobs and stages.

  • A job is an action to the software, such as compiling, testing, and deploying code.
  • A stage is a time frame in which a job is run, such as building, testing, staging, and production.

GitLab CI/CD uses runners to run jobs in a pipeline. If a runner successfully runs all jobs in a stage, the pipeline will automatically go to the next stage. If any jobs fail, the pipeline ends. For more information, see GitLab CI/CD Pipelines.

Prerequisites

Ensure you have a GitLab account.

Note: For more information on how to create a GitLab account, see Signing Up for GitLab.

Using GitLab CI/CD for Liquibase

You can use GitLab’s shared runners for your pipelines, which will create a virtual machine for each job and delete it after the job is complete. Alternatively, you can self-host runners by installing GitLab Runner.

The LiquibaseGitLabCICD repository contains a README and files for different setup pipelines:

  • Liquibase Command Line Interface (CLI)
  • Liquibase Maven commands with a Springboot app
  • Liquibase Gradle commands
  • Liquibase running in Docker
  • Liquibase running in a NodeJS wrapper

The repository contains the following configuration files for each project:

Project Folder Files
Docker Docker The SQL changelog file
Gradle Gradle_h2 The build.gradle and SQL changelog files
Liquibase CLI commands H2_project The XML changelog file
NodeJS NodeJS The index.js file and other pipeline files for different environments
Maven SalesManager_h2_version The pom.xml, application.properties, local.liquibase.properties, and SQL changelog files

The repository also contains a .gitlab-ci.yml file containing the jobs that runners will execute. All pipelines in the repository use runners hosted on Docker Images GitLab.

How to Use the Liquibase GitLab CI/CD Repository

To use the Liquibase GitLab CI/CD repository, follow these steps:

  • Open the repository and click the Fork button in the top-right corner of the page to create a copy for yourself. For more information about forking, see Project forking workflow.
  • Go to your newly forked “liquibasegitlabcicd” repository and follow the steps on Get started with GitLab CI/CD.
  • To run your job, click CI/CD on the left panel -> Pipelines -> Branches -> select a branch -> Run Pipeline.

You can adjust your CI/CD pipeline by adding more commands and flags to the .gitlab-ci.yml file.