-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzurePipeline.yaml
137 lines (124 loc) · 5.2 KB
/
AzurePipeline.yaml
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
136
137
# Condição para executar o build ao ter db_files.sql editado
trigger:
branches:
include:
- master
- pre-prod
- develop
- homolog
paths:
include:
- db_files.sql
# Condição para Pull Request
pr:
branches:
include:
- develop #CORPD0
# Variáveis definidas
variables:
- name: isDevelop
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/develop')]
# Estágio de Integração Contínua
stages:
- stage: ContinuosIntegration
pool:
name: Azure Pipelines
vmImage: "windows-2022"
jobs:
- job: ContinuosIntegration
steps:
# Gera pacotes para aplicação
- task: PowerShell@2
displayName: "Generate packages for application"
inputs:
targetType: filePath
filePath: "./src/main/resources/db/devops/gera-pacotes.ps1"
arguments: "-DefinitionName $(Build.DefinitionName) -BuildNumber $(Build.BuildNumber)"
# Valida objetos (Encoding)
- task: PythonScript@0
displayName: "Object validation (Encoding)"
inputs:
versionSpec: "3.x" # Versão de Python a ser usada
scriptSource: "filePath"
scriptPath: "./src/main/resources/db/devops/encoding-ci.py"
arguments: "-DefinitionName $(Build.DefinitionName) -BuildNumber $(Build.BuildNumber)"
# Copia os arquivos criados pelo executável para dentro do artefato
- task: CopyFiles@2
displayName: "Copy Files to $(Build.ArtifactStagingDirectory)"
inputs:
SourceFolder: ./
Contents: |
script/**
backup/**
chamador-$(Build.DefinitionName)-$(Build.BuildNumber).sql
chamador-status-$(Build.DefinitionName)-$(Build.BuildNumber).sql
chamador-backup-$(Build.DefinitionName)-$(Build.BuildNumber).sql
src/main/resources/db/devops/**
db_files.sql
TargetFolder: "$(Build.ArtifactStagingDirectory)"
# Publica os artefatos gerados para execução
- task: PublishBuildArtifacts@1
displayName: "Generate new artifact from scripts"
inputs:
ArtifactName: "$(Build.DefinitionName)-$(Build.BuildNumber)"
# Estágio de CD Release para CORPD0
- stage: CDReleaseCORPD0
dependsOn: ContinuosIntegration
condition: and(succeeded(), eq(variables.isDevelop, 'true'))
variables:
- group: deploy-corpd0 # Grupo com variáveis da CORPD0
jobs:
- deployment: AwaitingApprovalCodeAdmin
environment:
name: "deploy_corpd0"
pool: lbr001001-271
strategy:
runOnce:
deploy:
steps:
# Nome da base
- bash: |
cd ../$(Build.DefinitionName)-$(Build.BuildNumber)
$(ORACLE_HOME)/sqlplus $(usuario)/$(senha)@$(servidor):$(porta)/$(sid) @src/main/resources/db/devops/select_globalname.sql
timeoutInMinutes: 5
displayName: "BASE"
# Gerar backup
- bash: |
cd ../$(Build.DefinitionName)-$(Build.BuildNumber)
$(ORACLE_HOME)/sqlplus $(usuario)/$(senha)@$(servidor):$(porta)/$(sid) @chamador-backup-$(Build.DefinitionName)-$(Build.BuildNumber).sql
timeoutInMinutes: 60
displayName: "Generate Backup"
# Copiar backup
- task: CopyFiles@2
displayName: "Copy Files to Backup"
inputs:
SourceFolder: ../$(Build.DefinitionName)-$(Build.BuildNumber)
Contents: |
script/**
backup/**
TargetFolder: "$(Build.ArtifactStagingDirectory)"
# Publicar backup
- task: PublishBuildArtifacts@1
displayName: "Generate new artifact from backup"
inputs:
ArtifactName: "$(Build.DefinitionName)-$(Build.BuildNumber)-Mapfre"
# Comando SQL do chamador
- bash: |
cd ../$(Build.DefinitionName)-$(Build.BuildNumber)
$ORACLE_HOME/sqlplus $(usuario)/$(senha)@$(servidor):$(porta)/$(sid) @chamador-$(Build.DefinitionName)-$(Build.BuildNumber).sql
displayName: "Aplicando alterações na CORPD0"
# Comando SQL InvalidObject
- bash: |
cd ../$(Build.DefinitionName)-$(Build.BuildNumber)
TEMP_FILE=temp-invalid-objects.txt
FILE_BEFORE=temp-num-invalid-objects.txt
while read LINE; do
if [[ -n "${LINE// /}" ]] && [ "$LINE" != "OBJETOS_INVALIDOS" ] && [ "$LINE" != "-----------------" ]; then
echo "$LINE" >> $FILE_BEFORE
fi
done < $TEMP_FILE
rm $TEMP_FILE
displayName: "Objetos Invalidados"
# Mensagem de boas-vindas
- script: echo "Welcome, CORPD0 !!!"
displayName: "Welcome"