Skip to content

Commit 522aef2

Browse files
change defaults for code analysis to warning
1 parent afef754 commit 522aef2

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-2
lines changed

Azure/Azure-Templatized-YML-Pipeline/flyway-11.14/templates/vars.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ variables:
2626

2727
# $userName is not defined, use integratedSecurity in JDBC
2828
${{ if gt(length(join('', variables['userName'])), 0) }}:
29-
FLYWAY: 'flyway -check.code.failOnError=true -check.regexEnabled=false -check.rulesConfig="$(Build.SourcesDirectory)\templates\sqlfluff.cfg" -installedBy="$(Build.BuildId)" -reportEnabled=true -environment=target -environments.target.schemas="$(schemas)" -environments.check.schemas="$(schemas)" -baselineOnMigrate=true -errorOverrides=S0001:0:I- -baselineVersion=$(BASELINE_VERSION) -email="$(FLYWAY_EMAIL)" -token="$(FLYWAY_TOKEN)" -workingDirectory="$(WORKING_DIRECTORY)" -locations="filesystem:$(WORKING_DIRECTORY)\$(Build.Repository.Name)\migrations" -configFiles="$(WORKING_DIRECTORY)\$(Build.Repository.Name)\flyway.toml"'
29+
FLYWAY: 'flyway -check.code.failOnError=false -check.regexEnabled=false -check.rulesConfig="$(Build.SourcesDirectory)\templates\sqlfluff.cfg" -installedBy="$(Build.BuildId)" -reportEnabled=true -environment=target -environments.target.schemas="$(schemas)" -environments.check.schemas="$(schemas)" -baselineOnMigrate=true -errorOverrides=S0001:0:I- -baselineVersion=$(BASELINE_VERSION) -email="$(FLYWAY_EMAIL)" -token="$(FLYWAY_TOKEN)" -workingDirectory="$(WORKING_DIRECTORY)" -locations="filesystem:$(WORKING_DIRECTORY)\$(Build.Repository.Name)\migrations" -configFiles="$(WORKING_DIRECTORY)\$(Build.Repository.Name)\flyway.toml"'
3030

3131
# $userName is defined - password implicitly assumed defined
3232
${{ if le(length(join('', variables['userName'])), 0) }}:
33-
FLYWAY: 'flyway -check.code.failOnError=true -check.regexEnabled=false -check.rulesConfig="$(Build.SourcesDirectory)\templates\sqlfluff.cfg" -installedBy="$(Build.BuildId)" -reportEnabled=true -environment=target -environments.target.schemas="$(schemas)" -environments.check.schemas="$(schemas)" -baselineOnMigrate=true -errorOverrides=S0001:0:I- -baselineVersion=$(BASELINE_VERSION) -email="$(FLYWAY_EMAIL)" -token="$(FLYWAY_TOKEN)" -workingDirectory="$(WORKING_DIRECTORY)" -locations="filesystem:$(WORKING_DIRECTORY)\$(Build.Repository.Name)\migrations" -configFiles="$(WORKING_DIRECTORY)\$(Build.Repository.Name)\flyway.toml" -user="$(userName)" -password="$(password)"'
33+
FLYWAY: 'flyway -check.code.failOnError=false -check.regexEnabled=false -check.rulesConfig="$(Build.SourcesDirectory)\templates\sqlfluff.cfg" -installedBy="$(Build.BuildId)" -reportEnabled=true -environment=target -environments.target.schemas="$(schemas)" -environments.check.schemas="$(schemas)" -baselineOnMigrate=true -errorOverrides=S0001:0:I- -baselineVersion=$(BASELINE_VERSION) -email="$(FLYWAY_EMAIL)" -token="$(FLYWAY_TOKEN)" -workingDirectory="$(WORKING_DIRECTORY)" -locations="filesystem:$(WORKING_DIRECTORY)\$(Build.Repository.Name)\migrations" -configFiles="$(WORKING_DIRECTORY)\$(Build.Repository.Name)\flyway.toml" -user="$(userName)" -password="$(password)"'
3434

3535
BUILD_NAME: 'Repository-Snapshot'
3636
RELEASE_PREVIEW: 'Release-Preview.sql'

Gitlab/.gitlab-ci.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# GitLab CI/CD Pipeline for Flyway Database Migrations
2+
3+
stages:
4+
# - validate
5+
- migrate-test
6+
- migrate-prod
7+
8+
variables:
9+
FLYWAY_VERSION: "10.20.1"
10+
# Production database connection details stored in GitLab CI/CD Variables:
11+
# PROD_DB_URL, PROD_DB_USER, PROD_DB_PASSWORD
12+
# Test database runs in a temporary SQL Server container (see migrate:dev job)
13+
14+
# # Validate migrations before deploying
15+
# validate:
16+
# stage: validate
17+
# image: flyway/flyway:${FLYWAY_VERSION}
18+
# script:
19+
# - flyway -url="${DB_URL}" -user="${DB_USER}" -password="${DB_PASSWORD}" validate
20+
# - flyway -url="${DB_URL}" -user="${DB_USER}" -password="${DB_PASSWORD}" info
21+
# only:
22+
# - merge_requests
23+
# - main
24+
25+
# Deploy to Development
26+
migrate:dev:
27+
stage: migrate-test
28+
image:
29+
name: flyway/flyway:${FLYWAY_VERSION}
30+
entrypoint: [""]
31+
services:
32+
- name: postgres:15-alpine
33+
alias: postgres
34+
variables:
35+
POSTGRES_DB: testdb
36+
POSTGRES_USER: flywayuser
37+
POSTGRES_PASSWORD: flywaypass
38+
variables:
39+
TEST_DB_URL: "jdbc:postgresql://postgres:5432/testdb"
40+
DB_USER: "flywayuser"
41+
DB_PASSWORD: "flywaypass"
42+
script:
43+
- echo "Waiting for PostgreSQL to start..."
44+
- |
45+
for i in {1..15}; do
46+
if flyway -url="${TEST_DB_URL}" -user="${DB_USER}" -password="${DB_PASSWORD}" info > /dev/null 2>&1; then
47+
echo "PostgreSQL is ready!"
48+
break
49+
fi
50+
echo "Attempt $i: PostgreSQL not ready yet, waiting..."
51+
sleep 2
52+
done
53+
- echo "Running Flyway info..."
54+
- flyway -url="${TEST_DB_URL}" -user="${DB_USER}" -password="${DB_PASSWORD}" -baselineOnMigrate=true info
55+
- flyway -url="${TEST_DB_URL}" -user="${DB_USER}" -password="${DB_PASSWORD}" -baselineOnMigrate=true migrate
56+
- flyway -url="${TEST_DB_URL}" -user="${DB_USER}" -password="${DB_PASSWORD}" info
57+
environment:
58+
name: development
59+
only:
60+
- main
61+
62+
# Deploy to Production (manual trigger with protection)
63+
migrate:prod:
64+
stage: migrate-prod
65+
image:
66+
name: flyway/flyway:${FLYWAY_VERSION}
67+
entrypoint: [""]
68+
script:
69+
- flyway -url="${PROD_DB_URL}" -user="${PROD_DB_USER}" -password="${PROD_DB_PASSWORD}" info
70+
- flyway -url="${PROD_DB_URL}" -user="${PROD_DB_USER}" -password="${PROD_DB_PASSWORD}" migrate
71+
- flyway -url="${PROD_DB_URL}" -user="${PROD_DB_USER}" -password="${PROD_DB_PASSWORD}" info
72+
environment:
73+
name: production
74+
when: manual
75+
only:
76+
- main
77+
# Uncomment to require manual approval
78+
# needs:
79+
# - migrate:staging
80+
81+
82+
# Alternative: Using Flyway config file
83+
# migrate:with-config:
84+
# stage: migrate-dev
85+
# image: flyway/flyway:${FLYWAY_VERSION}
86+
# script:
87+
# - flyway -configFiles=/flyway/conf/flyway.conf migrate
88+
# artifacts:
89+
# paths:
90+
# - flyway-report.html
91+
# only:
92+
# - main
93+
94+
95+
# Alternative: Using Java with Flyway CLI installed
96+
# migrate:java:
97+
# stage: migrate-dev
98+
# image: openjdk:17-slim
99+
# before_script:
100+
# - apt-get update && apt-get install -y wget
101+
# - wget -qO- https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/${FLYWAY_VERSION}/flyway-commandline-${FLYWAY_VERSION}-linux-x64.tar.gz | tar xvz
102+
# - ln -s `pwd`/flyway-${FLYWAY_VERSION}/flyway /usr/local/bin/flyway
103+
# script:
104+
# - flyway -url="${DEV_DB_URL}" -user="${DEV_DB_USER}" -password="${DEV_DB_PASSWORD}" migrate
105+
# only:
106+
# - main

0 commit comments

Comments
 (0)