-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_pipeline.yaml
107 lines (93 loc) · 2.67 KB
/
deploy_pipeline.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
trigger:
- master
resources:
- repo: self
variables:
# Cria as variáveis de ambiente para conexão ao Container Registry
# Container Registry service connection variables
dockerRegistryServiceConnection: '747a3-87923b-237482c'
imageRepository: 'app-name'
containerRegistry: 'app-name.azurecr.io'
dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
tag: '$(Build.SourceVersion)'
branch: '$(Build.SourceBranch)'
# Agent VM image name
# Nome da imagem da VM do Agent
vmImageName: 'ubuntu-latest'
stages:
- stage: Install
displayName: Install dependencies
jobs:
- job: Install
displayName: Install dependencies
pool:
vmImage: $(vmImageName)
steps:
# Instala o Node
- task: NodeTool@0
inputs:
versionSpec: '16.x'
checkLatest: true
displayName: 'Install Node.js'
- script: |
npm install
npm run build
displayName: 'Install & build'
- stage: RunSonarQubeAnalysis
displayName: SonarQube Quality Gate Analysis
jobs:
- job:
displayName: SonarQube Quality Gate Analysis
pool:
vmImage: $(vmImageName)
steps:
# Executa a análise com base no quality gate do projeto e 'quebra' o build caso
# falhe
# Run the analysis based on project's quality gate and breaks the build if it fails
- task: SonarQubePrepare@5
inputs:
SonarQube: 'Sonarqube'
scannerMode: 'CLI'
configMode: 'file'
- task: SonarQubeAnalyze@5
- task: sonar-buildbreaker@8
inputs:
SonarQube: 'Sonarqube'
- stage: Build
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
displayName: Build and push stage
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
latest
- stage: Build_development
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))
displayName: Build and push stage - dev
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository)
dockerfile: $(dockerfilePath)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)-dev
latest-dev