This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
182 lines (163 loc) · 6.82 KB
/
azure-pipelines.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Node.js with webpack
# Build a Node.js project using the webpack CLI.
# Add steps that analyze code, save build artefacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
variables:
- name: dockerVersion
value: '19.03.5'
- group: dev-acr-secrets
trigger:
- master
# PR builds only when against these branches
pr:
- master
pool:
vmImage: 'ubuntu-latest'
jobs:
- job: version
displayName: Work out Version
steps:
- task: UseGitVersion@5
displayName: gitversion
inputs:
versionSpec: '5.x'
- script: echo "##vso[task.setvariable variable=semVer;isOutput=true]$(GitVersion.SemVer)"
name: setVersionStep
- script: echo semVer $(setVersionStep.semVer)
name: echovar
- job: buildAndTest
displayName: Build app and run tests
variables:
semVer: $[ dependencies.version.outputs['setVersionStep.semVer'] ]
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- script: |
npm install -g npm@latest
npm install -g webpack webpack-cli --save-dev
npm install
npm run build
displayName: 'NPM install'
- script: npm run test
displayName: 'Unit test'
- task: PublishTestResults@2
displayName: Publish unit test results
inputs:
testResultsFormat: NUnit
testResultsFiles: '$(System.DefaultWorkingDirectory)/unit-test-report.xml'
testRunTitle: Unit test results
failTaskOnFailedTests: true
condition: succeededOrFailed()
- script: npm run test:integration
displayName: 'Integration test'
- task: PublishTestResults@2
displayName: Publish integration test results
inputs:
testResultsFormat: NUnit
testResultsFiles: '$(System.DefaultWorkingDirectory)/integration-test-report.xml'
testRunTitle: Integration test results
failTaskOnFailedTests: true
condition: succeededOrFailed()
- job: dockerBuildAndPush
displayName: Build and push docker containers to the acr
variables:
semVer: $[ dependencies.version.outputs['setVersionStep.semVer'] ]
condition: succeeded()
dependsOn:
- version
- buildAndTest
steps:
- task: DockerInstaller@0
inputs:
dockerVersion: $(dockerVersion)
- task: DockerCompose@0
displayName: 'Build: Dev'
condition: succeeded()
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'NHSAPP-BuyingCatalogue (Non-Prod)'
azureContainerRegistry: '{"loginServer":"gpitfuturesdevacr.azurecr.io", "id" : "/subscriptions/7b12a8a2-f06f-456f-b6f9-aa2d92e0b2ec/resourceGroups/gpitfutures-dev-rg-acr/providers/Microsoft.ContainerRegistry/registries/gpitfuturesdevacr"}'
dockerComposeFile: '**/docker-compose-build.yml'
action: 'Build services'
additionalImageTags: '$(semVer)'
includeSourceTags: true
- task: DockerCompose@0
displayName: 'Push: Dev'
condition: succeeded()
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'NHSAPP-BuyingCatalogue (Non-Prod)'
azureContainerRegistry: '{"loginServer":"gpitfuturesdevacr.azurecr.io", "id" : "/subscriptions/7b12a8a2-f06f-456f-b6f9-aa2d92e0b2ec/resourceGroups/gpitfutures-dev-rg-acr/providers/Microsoft.ContainerRegistry/registries/gpitfuturesdevacr"}'
dockerComposeFile: '**/docker-compose-build.yml'
action: 'Push services'
additionalImageTags: '$(semVer)'
includeSourceTags: true
- task: HelmInstaller@1
displayName: 'Install helm'
inputs:
helmVersionToInstall: 'latest'
- bash: |
cd charts
helm package \
--version $(semVer) \
--app-version $(semVer) \
pb
failOnStderr: true
displayName: 'Helm package'
- bash: |
cd charts
chartPackage=$(ls pb-*.tgz)
az acr helm push --force \
-n "gpitfuturesdevacr" \
-u "gpitfuturesdevacr" \
-p $(gpitfuturesdevacr-pass) \
$chartPackage
failOnStderr: false
name: helmPush
displayName: 'Push helm to az acr'
- task: DockerCompose@0
displayName: 'Build: Test'
condition: and(succeeded(), ne(variables['build.reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'NHSAPP-BuyingCatalogue (Non-Prod)'
azureContainerRegistry: '{"loginServer":"gpitfuturestestacr.azurecr.io", "id" : "/subscriptions/7b12a8a2-f06f-456f-b6f9-aa2d92e0b2ec/resourceGroups/gpitfutures-test-rg-acr/providers/Microsoft.ContainerRegistry/registries/gpitfuturestestacr"}'
dockerComposeFile: '**/docker-compose-build.yml'
action: 'Build services'
additionalImageTags: '$(semVer)'
includeSourceTags: true
- task: DockerCompose@0
displayName: 'Push: Test'
condition: and(succeeded(), ne(variables['build.reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'NHSAPP-BuyingCatalogue (Non-Prod)'
azureContainerRegistry: '{"loginServer":"gpitfuturestestacr.azurecr.io", "id" : "/subscriptions/7b12a8a2-f06f-456f-b6f9-aa2d92e0b2ec/resourceGroups/gpitfutures-test-rg-acr/providers/Microsoft.ContainerRegistry/registries/gpitfuturestestacr"}'
dockerComposeFile: '**/docker-compose-build.yml'
action: 'Push services'
additionalImageTags: '$(semVer)'
includeSourceTags: true
- task: DockerCompose@0
displayName: 'Build: Prod'
condition: and(succeeded(), ne(variables['build.reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'NHSAPP-BuyingCatalogue (Prod)'
azureContainerRegistry: '{"loginServer":"gpitfuturesprodacr.azurecr.io", "id" : "/subscriptions/d1be8dbc-1a9f-4b7b-ba51-037116110e00/resourceGroups/gpitfutures-prod-rg-acr/providers/Microsoft.ContainerRegistry/registries/gpitfuturesprodacr"}'
dockerComposeFile: '**/docker-compose-build.yml'
action: 'Build services'
additionalImageTags: '$(semVer)'
includeSourceTags: true
- task: DockerCompose@0
displayName: 'Push: Prod'
condition: and(succeeded(), ne(variables['build.reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
inputs:
containerregistrytype: 'Azure Container Registry'
azureSubscription: 'NHSAPP-BuyingCatalogue (Prod)'
azureContainerRegistry: '{"loginServer":"gpitfuturesprodacr.azurecr.io", "id" : "/subscriptions/d1be8dbc-1a9f-4b7b-ba51-037116110e00/resourceGroups/gpitfutures-prod-rg-acr/providers/Microsoft.ContainerRegistry/registries/gpitfuturesprodacr"}'
dockerComposeFile: '**/docker-compose-build.yml'
action: 'Push services'
additionalImageTags: '$(semVer)'
includeSourceTags: true