Skip to content

Commit 65dc943

Browse files
authored
Merge pull request #2 from paulparkinson/main
init part2 includes liquibase
2 parents b0c5e45 + 4adf99d commit 65dc943

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Deploy to Azure Kubernetes Service
2+
# Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service
3+
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
4+
5+
trigger:
6+
- main
7+
8+
resources:
9+
- repo: self
10+
11+
variables:
12+
13+
# Container registry service connection established during pipeline creation
14+
dockerRegistryServiceConnection: 'ba554595-2da8-4cf6-88c4-a57c75966491'
15+
imageRepository: 'multicloudapp'
16+
containerRegistry: 'multicloud.azurecr.io'
17+
dockerfilePath: '**/Dockerfile'
18+
tag: '$(Build.BuildId)'
19+
imagePullSecret: 'multicloud2012b828-auth'
20+
21+
# Agent VM image name
22+
vmImageName: 'ubuntu-latest'
23+
24+
# Name of the new namespace being created to deploy the PR changes.
25+
k8sNamespaceForPR: 'review-app-$(System.PullRequest.PullRequestId)'
26+
27+
stages:
28+
- stage: Build
29+
displayName: Build stage
30+
jobs:
31+
- job: Build
32+
displayName: Build
33+
pool:
34+
vmImage: $(vmImageName)
35+
steps:
36+
- task: JavaToolInstaller@0
37+
inputs:
38+
versionSpec: '17'
39+
jdkArchitectureOption: 'x64'
40+
jdkSourceOption: 'PreInstalled'
41+
- task: Maven@4
42+
inputs:
43+
mavenPomFile: 'pom.xml'
44+
publishJUnitResults: true
45+
testResultsFiles: '**/surefire-reports/TEST-*.xml'
46+
javaHomeOption: 'JDKVersion'
47+
mavenVersionOption: '1.17'
48+
mavenAuthenticateFeed: false
49+
effectivePomSkip: false
50+
sonarQubeRunAnalysis: false
51+
- task: Docker@2
52+
displayName: Build and push an image to container registry
53+
inputs:
54+
command: buildAndPush
55+
repository: $(imageRepository)
56+
dockerfile: $(dockerfilePath)
57+
containerRegistry: $(dockerRegistryServiceConnection)
58+
tags: |
59+
$(tag)
60+
61+
- upload: manifests
62+
artifact: manifests
63+
- script: |
64+
- script: |
65+
echo Downloading Liquibase and Oracle JDBC driver
66+
wget https://github.com/liquibase/liquibase/releases/download/v4.4.3/liquibase-4.4.3.tar.gz
67+
tar -xzf liquibase-4.4.3.tar.gz
68+
wget https://path/to/ojdbc8.jar
69+
displayName: 'Install Liquibase and Oracle JDBC'
70+
71+
72+
- stage: Deploy
73+
displayName: Deploy stage
74+
dependsOn: Build
75+
76+
jobs:
77+
78+
- deployment: Deploy
79+
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')))
80+
displayName: Deploy
81+
pool:
82+
vmImage: $(vmImageName)
83+
environment: 'paulparkinsonazuredevopsoracledatabase-8684.default'
84+
strategy:
85+
runOnce:
86+
deploy:
87+
steps:
88+
- task: KubernetesManifest@0
89+
displayName: Create imagePullSecret
90+
inputs:
91+
action: createSecret
92+
secretName: $(imagePullSecret)
93+
dockerRegistryEndpoint: $(dockerRegistryServiceConnection)
94+
95+
- script: |
96+
yq eval '.spec.template.spec.containers[0].env += [{"name": "AZURE_LOG_LEVEL", "value": "verbose"}, {"name": "AZURE_CLIENT_ID", "value": "$(AZURE_CLIENT_ID)"}, {"name": "AZURE_CLIENT_SECRET", "value": "$(AZURE_CLIENT_SECRET)"}, {"name": "AZURE_TENANT_ID", "value": "$(AZURE_TENANT_ID)"}]' -i $(Pipeline.Workspace)/manifests/deployment.yml
97+
displayName: 'Add Environment Variable with yq'
98+
- task: KubernetesManifest@0
99+
displayName: Deploy to Kubernetes cluster
100+
inputs:
101+
action: deploy
102+
manifests: |
103+
$(Pipeline.Workspace)/manifests/deployment.yml
104+
$(Pipeline.Workspace)/manifests/service.yml
105+
imagePullSecrets: |
106+
$(imagePullSecret)
107+
containers: |
108+
$(containerRegistry)/$(imageRepository):$(tag)
109+
- script: |
110+
echo Setting up environment variables
111+
export DB_HOST=$(DB_HOST)
112+
export DB_PORT=$(DB_PORT)
113+
export DB_SERVICE_NAME=$(DB_SERVICE_NAME)
114+
export DB_USERNAME=$(DB_USERNAME)
115+
export DB_PASSWORD=$(DB_PASSWORD)
116+
117+
echo Running Liquibase update
118+
./liquibase --defaultsFile=path/to/liquibase.properties update
119+
displayName: 'Run Liquibase Update'
120+
env:
121+
DB_HOST: $(DB_HOST)
122+
DB_PORT: $(DB_PORT)
123+
DB_SERVICE_NAME: $(DB_SERVICE_NAME)
124+
DB_USERNAME: $(DB_USERNAME)
125+
DB_PASSWORD: $(DB_PASSWORD)
126+

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ stages:
8989
- script: |
9090
yq eval '.spec.template.spec.containers[0].env += [{"name": "AZURE_LOG_LEVEL", "value": "verbose"}, {"name": "AZURE_CLIENT_ID", "value": "$(AZURE_CLIENT_ID)"}, {"name": "AZURE_CLIENT_SECRET", "value": "$(AZURE_CLIENT_SECRET)"}, {"name": "AZURE_TENANT_ID", "value": "$(AZURE_TENANT_ID)"}]' -i $(Pipeline.Workspace)/manifests/deployment.yml
9191
displayName: 'Add Environment Variable with yq'
92+
9293
- task: KubernetesManifest@0
9394
displayName: Deploy to Kubernetes cluster
9495
inputs:

db/changelog/db.changelog-master.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<databaseChangeLog
4+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
7+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
8+
9+
<changeSet id="1" author="your_name">
10+
<createTable tableName="cicd_test_table">
11+
<column name="testvalue" type="VARCHAR2(64)"/>
12+
</createTable>
13+
</changeSet>
14+
15+
</databaseChangeLog>

liquibase.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
driver: oracle.jdbc.OracleDriver
2+
url: jdbc:oracle:thin:@//${DB_HOST}:${DB_PORT}/${DB_SERVICE_NAME}
3+
username: ${DB_USERNAME}
4+
password: ${DB_PASSWORD}
5+
changeLogFile: db/changelog/db.changelog-master.xml
6+
classpath: ojdbc8.jar

0 commit comments

Comments
 (0)