Bitbucket
Published 13 January 2023
Here we are going to cover a creation of a simple Flyway Pipeline for independent of a database system.
In this example we are using the native Bitbucket pipeline runners.
Hence flyway will install on the runner with every run on the pipeline.
Yaml file
pipelines: default: - step: name: Install Flyway caches: - flyway script: - mkdir -p ~/flyway - wget -qO- https://download.red-gate.com/maven/release/com/redgate/flyway/flyway-commandline/10.14.0/flyway-commandline-10.14.0-linux-x64.tar.gz | tar -xz -C ~/flyway - ln -s ~/flyway/flyway-10.14.0/flyway /usr/local/bin/flyway - step: name: Test Stage caches: - flyway script: - ~/flyway/flyway-10.14.0/flyway migrate -user=$DATABASE_USER -password=$DATABASE_PASSWORD -url=$TEST_DB -locations="filesystem:./migrations" -licenseKey=$LICENSE_KEY - step: name: Staging Stage caches: - flyway script: - ~/flyway/flyway-10.14.0/flyway migrate -user=$DATABASE_USER -password=$DATABASE_PASSWORD -url=$STAGING_DB -locations="filesystem:./migrations" -licenseKey=$LICENSE_KEY definitions: caches: flyway: ~/flyway
Additionaly you need to add the pipeline Variables in Bitbucket for the pipeline to run:
- DATABASE_USER - Username that has access to the dtabase
- DATABASE_PASSWORD - Password for the mentioned user (Do not forget to mark it as secured)
- TEST_DB - jdbc string to connect to the test database.
- STAGING_DB - jdbc string to connect to the staging database.
- LICENSE_KEY - Flyway command line license key
Here you can see a postres example Yaml file for Attlasian Bitbucket
Sample pipeline at https://github.com/red-gate/Flyway-Sample-Pipelines/tree/main/Bitbucket.