Skip to content

Commit 2476e45

Browse files
committed
Adding pipeline
1 parent 4dfd0ca commit 2476e45

6 files changed

Lines changed: 216 additions & 10 deletions

File tree

.azure_templates/t-pipeline-extend-cicd.yml

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ parameters:
7171
default: ""
7272
- name: displayName
7373
default: ""
74-
- name: installsource
74+
- name: runliquibase
7575
type: object
7676
default:
7777
- name: work_dir
@@ -82,6 +82,21 @@ parameters:
8282
default: "oracle"
8383
- name: masterchangelogfile
8484
default: ""
85+
- name: runflyway
86+
type: object
87+
default:
88+
- name: config_dir
89+
default: ""
90+
- name: config_file
91+
default: ""
92+
- name: migrations_dir
93+
default: ""
94+
- name: user
95+
default: "sys"
96+
- name: password
97+
default: "oracle"
98+
- name: configfile
99+
default: ""
85100
- name: execute_tests
86101
type: object
87102
default:
@@ -153,8 +168,8 @@ parameters:
153168
- name: script
154169
default: ""
155170
- name: displayName
156-
default: ""
157-
- name: installsource
171+
default: ""
172+
- name: runliquibase
158173
type: object
159174
default:
160175
- name: work_dir
@@ -164,7 +179,18 @@ parameters:
164179
- name: password
165180
default: "oracle"
166181
- name: masterchangelogfile
167-
default: ""
182+
default: ""
183+
- name: runflyway
184+
type: object
185+
default:
186+
- name: work_dir
187+
default: ""
188+
- name: user
189+
default: "sys"
190+
- name: password
191+
default: "oracle"
192+
- name: configfile
193+
default: ""
168194

169195
stages:
170196
- ${{ if parameters.enableBuild }}:
@@ -204,14 +230,24 @@ stages:
204230
script: ${{ script.script}}
205231
displayName: ${{ script.displayName}}
206232
# Execute Liquibase
207-
- ${{ each liquibase in builddatabases.installsource }}:
233+
- ${{ each liquibase in builddatabases.runliquibase }}:
208234
- template: t-task-extend-sqlcl-liquibase.yml
209235
parameters:
210236
connectionString: ${{ builddatabases.connectionString}}
211237
work_dir: ${{ liquibase.work_dir }}
212238
user: ${{ liquibase.user }}
213239
password: ${{ liquibase.password }}
214240
masterchangelogfile: ${{ liquibase.masterchangelogfile }}
241+
# Execute Flyway
242+
- ${{ each flyway in builddatabases.runflyway }}:
243+
- template: t-task-extend-flyway.yml
244+
parameters:
245+
connectionString: ${{ builddatabases.connectionString}}
246+
config_dir: ${{ flyway.config_dir }}
247+
config_file: ${{ flyway.config_file }}
248+
migrations_dir: ${{ flyway.migrations_dir }}
249+
user: ${{ flyway.user }}
250+
password: ${{ flyway.password }}
215251
# Execute utplsql tests
216252
- ${{ each runutplsql in builddatabases.execute_tests }}:
217253
- template: t-task-extend-utplsqlcli.yml
@@ -304,7 +340,7 @@ stages:
304340
script: ${{ script.script}}
305341
displayName: ${{ script.displayName}}
306342
# Execute Liquibase
307-
- ${{ each liquibase in stage.installsource }}:
343+
- ${{ each liquibase in stage.runliquibase }}:
308344
- template: t-task-extend-sqlcl-liquibase.yml
309345
parameters:
310346
connectionString: ${{ stage.connectionString}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
parameters:
2+
- name: connectionString
3+
default: ""
4+
- name: config_dir
5+
default: ""
6+
- name: config_file
7+
default: ""
8+
- name: migrations_dir
9+
default: ""
10+
- name: user
11+
default: "sys"
12+
- name: password
13+
default: "oracle"
14+
- name: configfile
15+
default: ""
16+
17+
steps:
18+
- task: Docker@2
19+
displayName: Docker Login
20+
inputs:
21+
containerRegistry: ${{ parameters.containerRegistry }}
22+
command: 'login'
23+
- bash: |
24+
time docker pull flyway/flyway-azure:latest-alpine flyway
25+
# start the docker container (DB)
26+
time docker run --rm \
27+
-v ${{ parameters.migrations_dir }}:/flyway/sql \
28+
-v ${{ parameters.config_dir }}:/flyway/conf \
29+
-v /absolute/path/to/my/driverdir:/flyway/drivers \
30+
flyway/flyway-azure:latest-alpine migrate \
31+
-url=jdbc:oracle:thin:@//${{ parameters.connectionString }} \
32+
-configFiles="${{ parameters.config_file }}" \
33+
-user="${{ parameters.user }}" \
34+
-password="${{ parameters.password }}"
35+
36+
exit $?
37+
displayName: 'Run Flyway migration'
38+

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
This is a demo project using [utPLSQL v3](https://github.com/utPLSQL/utPLSQL) for unit testing of Oracle PLSQL code.
11-
The project is also taking benefit of Continuous Integration with Travis CI server as well as static code analysis, code coverage and test results reporting using SonarQube.
11+
The project is also taking benefit of Continuous Integration with Travis CI server as well as static code analysis, code coverage and test results reporting using SonarCloud.
1212

1313
With every commit made to the github repository, a build job is executed using [Travis](https://travis-ci.org/utPLSQL/utPLSQL-demo-project) CI.
1414

@@ -26,7 +26,7 @@ The build process consists of following steps:
2626
## Demo project using utPLSQL, Azure Devops and SQLCL Liquibase for continuous integration of PLSQL and SQL code.
2727

2828
This is a demo project using [utPLSQL v3](https://github.com/utPLSQL/utPLSQL) for unit testing of Oracle PLSQL code.
29-
The project is also taking benefit of Continuous Integration with Azure Devops server as well as static code analysis, code coverage and test results reporting using SonarQube.
29+
The project is also taking benefit of Continuous Integration with Azure Devops server as well as static code analysis, code coverage and test results reporting using SonarCloud.
3030

3131
With every commit made to the github repository, a pipeline is executed using [AzureDevops](https://dev.azure.com/utplsql/utplsql/_build) CI.
3232
The pipeline is setup into stages.
@@ -39,6 +39,7 @@ The pipeline is setup into stages.
3939
- Execute Liquibase update to deploy code
4040
- Execute tests
4141
- Publish test results
42+
- Execute sonar analysis
4243
- Copy source code and publish to artefact staging for publish
4344

4445

@@ -48,3 +49,6 @@ The pipeline is setup into stages.
4849
- Provision a database from docker *( this step most likely you will not run as these databases will exists already)*
4950
- Create user to deploy code to *( this step most likely you will not run as the user will exists already)*
5051
- Execute Liquibase update to deploy code
52+
53+
54+
## Demo project using utPLSQL, Azure Devops and Flyway for continuous integration of PLSQL and SQL code.

utplsql-cicd-flyway-demo.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
trigger:
2+
- none
3+
4+
pool:
5+
vmImage: ubuntu-latest
6+
7+
variables:
8+
# Using this variable, the template references the correct variable template file (vars-dev.yaml, vars-qa.yaml or vars-prd.yaml) from the vars folder.
9+
- template: .azure_templates/vars/vars-global.yml
10+
- name: SQLCL_DIR
11+
value: $(Build.BinariesDirectory)/sqlcl
12+
- name : UTPLSQL_DIR
13+
value: $(Build.BinariesDirectory)/utPLSQL
14+
- name : UTPLSQL_CLI_DIR
15+
value: $(Build.BinariesDirectory)/utPLSQL-cli
16+
- name : UTPLSQL_CLI_VERSION
17+
value: 'v3.1.8'
18+
- name : UTPLSQL_VERSION
19+
value: 'v3.1.11'
20+
- name : DB_USER
21+
value: ut3_demo
22+
- name : DB_PASS
23+
value: ut3_demo
24+
- name: artifactName
25+
value: ReleaseArtifact
26+
27+
extends:
28+
template: .azure_templates/t-pipeline-extend-cicd.yml
29+
parameters:
30+
enableBuild: true
31+
enableDeployment: false
32+
enableAnalysis: false
33+
buildDatabase:
34+
- name: BuildDatabase
35+
containerRegistry: ${{ variables.containerRegistry }}
36+
dockerRepo: ${{ variables.dockerRepo }}
37+
connectionString: "127.0.0.1:1521/ORCLCDB"
38+
environment: "build"
39+
artifactName: ${{ variables.artifactName }}
40+
packages:
41+
- name: sqlcl
42+
download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip"
43+
unpack_location: "$(Build.BinariesDirectory)"
44+
url: ${{ variables.sqlclUrl }}
45+
archive: "zip"
46+
addtoPath: "$(SQLCL_DIR)/bin"
47+
- name: utlplsqlcli
48+
download_location: "$(Build.BinariesDirectory)/utPLSQL-cli.zip"
49+
unpack_location: "$(Build.BinariesDirectory)"
50+
url: ${{ variables.utplsqlcliUrl }}
51+
archive: "zip"
52+
addToPath: "$(UTPLSQL_CLI_DIR)/bin"
53+
createDatabase:
54+
- dbname: UTBUILD
55+
oracleVersion: "19c-se2-small"
56+
dockerPortMap: "1521"
57+
dockerOptions: "--shm-size=1g"
58+
scripts:
59+
- displayName: "Install utPLSQL"
60+
user: "sys"
61+
password: "oracle"
62+
script: "install_headless.sql UT3 UT3 users"
63+
work_dir: "${UTPLSQL_DIR}/source"
64+
- displayName: "Create Test User"
65+
user: "sys"
66+
password: "oracle"
67+
script: "source/create_user.sql"
68+
work_dir: "$(Build.SourcesDirectory)"
69+
- displayName: "Install Tests"
70+
user: "$(DB_USER)"
71+
password: "$(DB_PASS)"
72+
script: "test/install.sql"
73+
work_dir: "$(Build.SourcesDirectory)"
74+
runflyway:
75+
- config_dir: "$(Build.SourcesDirectory)"
76+
config_file: ${{ flyway.config_file }}
77+
migrations_dir: ${{ flyway.migrations_dir }}
78+
user: $(DB_USER)
79+
password: $(DB_PASS)
80+
gitCheckoutDetails:
81+
- gitRepo: ${{ variables.gitRepo }}
82+
branch: $(UTPLSQL_VERSION)
83+
checkoutDir: $(UTPLSQL_DIR)
84+
execute_tests:
85+
- work_dir: $(Build.SourcesDirectory)
86+
test_user: $(DB_USER)
87+
test_pwd: $(DB_PASS)
88+
source_path: "source"
89+
test_path: "test"
90+
options: "--debug --failure-exit-code=0"
91+
92+
deployStages:
93+
- name: ReleaseCode
94+
display_name: Deploy code to Test Env
95+
dependsOn: BuildDatabase
96+
target_environment: TEST
97+
connectionString: "127.0.0.1:1521/ORCLCDB"
98+
containerRegistry: ${{ variables.containerRegistry }}
99+
dockerRepo: ${{ variables.dockerRepo }}
100+
createDatabase:
101+
- dbname: UTTEST
102+
oracleVersion: "19c-se2-small"
103+
dockerPortMap: "1521"
104+
dockerOptions: "--shm-size=1g"
105+
packages:
106+
- name: sqlcl
107+
download_location: "$(Build.BinariesDirectory)/sqlcl-latest.zip"
108+
unpack_location: "$(Build.BinariesDirectory)"
109+
url: ${{ variables.sqlclUrl }}
110+
archive: "zip"
111+
addtoPath: "$(SQLCL_DIR)/bin"
112+
scripts:
113+
- displayName: "Create Test User"
114+
user: "sys"
115+
password: "oracle"
116+
script: "source/create_user.sql"
117+
work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}"
118+
installsource:
119+
- work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}"
120+
user: $(DB_USER)
121+
password: $(DB_PASS)
122+
masterchangelogfile: "utplsql_changelog.xml"
123+

utplsql-cicd-liquibase-demo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extends:
7171
password: "$(DB_PASS)"
7272
script: "test/install.sql"
7373
work_dir: "$(Build.SourcesDirectory)"
74-
installsource:
74+
runliquibase:
7575
- work_dir: "$(Build.SourcesDirectory)"
7676
user: $(DB_USER)
7777
password: $(DB_PASS)
@@ -114,7 +114,7 @@ extends:
114114
password: "oracle"
115115
script: "source/create_user.sql"
116116
work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}"
117-
installsource:
117+
runliquibase:
118118
- work_dir: "$(Pipeline.Workspace)/${{ variables.artifactName }}"
119119
user: $(DB_USER)
120120
password: $(DB_PASS)

utplsql_flyway.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
flyway.schemas=ut3_demo
2+
flyway.table=schema_history
3+
flyway.outOfOrder=false
4+
flyway.baselineOnMigrate=false
5+
flyway.installedBy=utplsqldemo

0 commit comments

Comments
 (0)