Integrating with GitLab CI
This tutorial will show you the steps to integrate Bytebase CLI
bb into a GitLab project. You will set up a pipeline automating the database schema change along with the code change, which brings your team’s DevOps automation to a new level.
- A GitLab Project. (GitLab.com or GitLab CE/EE. We use GitLab.com for this tutorial.)
- Self-managed GitLab Runner on a Linux machine. (You can follow the GitLab Runner docs to install)
- A MySQL database that is network accessible by the GitLab Runner.
bb on GitLab Runner
On your GitLab Runner shell prompt, paste the following command:
bb --version to check if
bb is installed.
You can go back to overview for more installation details.
Register GitLab Runner to a GitLab Project
In your GitLab Project, go to Settings > CI/CD > Runners, click the Show Runner Installation Instructions button, and follow the instructions to register runner.
From the shell prompt, add tag
bb-runner to specify this runner has
Configure GitLab CI
bb configures --dsn to access databases. Here are a few examples:
You also need to setup DSN secret to make this workflow available:
Go to Setting > CI/CD > Variables, add your DSN as
Trigger a Migration
Finally, you can trigger a migration by adding a new commit to your GitLab project.
Commit a script to
dev/ and check if this job runs correctly:
The schema snapshots before and after the migration are stored in artifacts:
You can browse this job detail on GitLab.com.