-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines-prod.yml
135 lines (125 loc) · 4.63 KB
/
azure-pipelines-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
parameters:
- name: LBCOMMAND
displayName: Choose a Liquibase command to run
values:
- update
- rollback
default: update
- name: TAG
displayName: Specify a tag when LBCOMMAND=UPDATE
type: string
default: release1
- name: ARTIFACTNUMBER
displayName: Artifact Number to use for PROD deployment and rollback # Human-readable name for the parameter
type: string
default: 0
- name: ROLLBACKTAG
displayName: Specify a tag when LBCOMMAND=ROLLBACK
type: string
default: release1
pr:
branches:
include:
- release
# Trigger on merges to any branch
trigger: none
# trigger:
# branches:
# include:
# - 'dev'
# - 'release'
# - 'prod'
# - 'AB#*'
name: $(Application.Name)-$(Build.BuildId)-PROD
variables:
- template: variables.yml
- group: Liquibase_Variables
pool:
name: $(Agent.PoolName)
stages:
- stage: PROD_Update
# condition: and(true, contains(variables['system.pullRequest.targetBranchName'], 'release'))
condition: and (true, contains(variables['Build.SourceBranch'], 'release'), eq('${{ parameters.LBCOMMAND }}', 'update'))
pool: Windows
jobs:
- job: DBUpdate
displayName: 'DB Update'
steps:
- checkout: none # Disable repository checkout for this step.
# Download an artifact named 'WebApp' from a specific build run to 'bin' in $(Build.SourcesDirectory)
- task: DownloadPipelineArtifact@2
displayName: 'Download-Artifact-${{ parameters.ARTIFACTNUMBER }}'
inputs:
buildType: 'specific'
artifactName: '$(Application.Name)-${{ parameters.ARTIFACTNUMBER }}'
targetPath: $(Build.SourcesDirectory)
project: 'Engie'
definition: ALPS DB - UAT
buildVersionToDownload: 'specific'
pipelineId: ${{ parameters.ARTIFACTNUMBER }}
itemPattern: |
sqlcode/**
changelog.xml
- task: PowerShell@2
displayName: 'Liquibase-Flow'
inputs:
targetType: 'inline'
script: |
echo "========== Database UPDATE ==========="
echo parameters.LBCOMMAND=${{ parameters.LBCOMMAND }}
echo SCHEMA=${env:SCHEMA}
echo ROLLBACKTAG=${env:ROLLBACKTAG}
echo Build.BuildId=$(Build.BuildId)
dir
C:\agent\_work\_tool\liquibase-4.24.0\liquibase.bat flow --flow-file=liquibase.flowfile-cd.yaml
Write-Host Last exit code: $LASTEXITCODE
env:
LBCOMMAND: ${{ parameters.LBCOMMAND }}
SCHEMA: $(PROD_SCHEMA)
TAG: ${{ parameters.TAG }} # When updating PROD, the TAG is user provided parameter which is also the artifact from UAT
LIQUIBASE_COMMAND_URL: $(PROD_URL)
LIQUIBASE_COMMAND_USERNAME: $(PROD_USERNAME)
LIQUIBASE_COMMAND_PASSWORD: $(PROD_PASSWORD)
- stage: PROD_Rollback
# condition: and(true, contains(variables['system.pullRequest.targetBranchName'], 'release'))
condition: and (true, contains(variables['Build.SourceBranch'], 'release'), eq('${{ parameters.LBCOMMAND }}', 'rollback'))
pool: Windows
jobs:
- job: DBRollback
displayName: 'DB Rollback tag=${{ parameters.ROLLBACKTAG }}'
steps:
- checkout: none # Disable repository checkout for this step.
# Download an artifact named 'WebApp' from a specific build run to 'bin' in $(Build.SourcesDirectory)
- task: DownloadPipelineArtifact@2
displayName: 'Download-Artifact-${{ parameters.ARTIFACTNUMBER }}'
inputs:
buildType: 'specific'
artifactName: '$(Application.Name)-${{ parameters.ARTIFACTNUMBER }}'
targetPath: $(Build.SourcesDirectory)
project: 'Engie'
definition: ALPS DB - UAT
buildVersionToDownload: 'specific'
pipelineId: ${{ parameters.ARTIFACTNUMBER }}
itemPattern: |
sqlcode/**
changelog.xml
- task: PowerShell@2
displayName: 'Liquibase-Flow'
inputs:
targetType: 'inline'
script: |
echo "========== Database ROLLBACK ==========="
echo parameters.LBCOMMAND=${{ parameters.LBCOMMAND }}
echo SCHEMA=${env:SCHEMA}
echo ROLLBACKTAG=${env:ROLLBACKTAG}
echo Build.BuildId=$(Build.BuildId)
dir
C:\agent\_work\_tool\liquibase-4.24.0\liquibase.bat flow --flow-file=liquibase.flowfile-cd-rollback.yaml
Write-Host Last exit code: $LASTEXITCODE
env:
LBCOMMAND: ${{ parameters.LBCOMMAND }}
SCHEMA: $(PROD_SCHEMA)
ROLLBACKTAG: ${{ parameters.ROLLBACKTAG }} # When rolling back PROD, the ROLLBACKTAG is user provided parameter
LIQUIBASE_COMMAND_URL: $(PROD_URL)
LIQUIBASE_COMMAND_USERNAME: $(PROD_USERNAME)
LIQUIBASE_COMMAND_PASSWORD: $(PROD_PASSWORD)