-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
275 lines (256 loc) · 10.8 KB
/
azure-pipelines.yml
File metadata and controls
275 lines (256 loc) · 10.8 KB
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, upload, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
schedules:
# Run from Monday to Friday at 2:0 UTC (https://docs.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml#cron-syntax)
- cron: "0 2 * * 1-5"
displayName: Nightly build
branches:
include:
- master
always: true
trigger:
- master
pool:
vmImage: ubuntu-latest
variables:
- group: sonar-scanner-azdo-variables
- group: artifactory_access
- name: System.debug
value: true
- name: NPM_CONFIG_registry
value: $(ARTIFACTORY_URL)/api/npm/npm
- name: isMain
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
- name: azureBranch
value: $[coalesce(variables['System.PullRequest.SourceBranch'], 'master')]
lockBehavior: sequential
stages:
- stage: build
displayName: "Build:"
jobs:
- job: npminstall
displayName: "NPM Install, CI and Build"
variables:
publisher: $(SonarSourceITPublisher)
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: Cache@2
inputs:
key: 'version2 | npm | "$(Agent.OS)" | **/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(npm_config_cache)
displayName: Cache npm
- task: Bash@3
displayName: "Update NPM"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
npm_config_cache: $(npm_config_cache)
inputs:
targetType: "inline"
script: |
sudo -E npm i -g npm@11
sudo chown -R $(whoami):$(whoami) "$npm_config_cache" 2>/dev/null || true
- task: Npm@1
displayName: "Install all extension dependencies"
env:
ARTIFACTORY_TOKEN: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
command: "install"
- task: Bash@3
displayName: "Append build id in version in manifests"
inputs:
targetType: "inline"
script: |
npx gulp ci:azure:hotfix-extensions-version
npx gulp ci:azure:hotfix-tasks-version
- task: Npm@1
displayName: "Create dogfood extension"
inputs:
command: "custom"
customCommand: "run test-build -- --publisher $(publisher)"
- task: CopyFiles@2
displayName: "Copy dogfood extensions to build directory"
inputs:
SourceFolder: "$(Build.SourcesDirectory)/dist"
Contents: "*.vsix"
TargetFolder: "$(Agent.BuildDirectory)/extensions/dogfood"
- task: Bash@3
displayName: "Suffix task names with *Test for the test extension"
inputs:
targetType: "inline"
script: |
npx gulp ci:azure:hotfix-tasks-names
- task: Npm@1
displayName: "Create test extension"
inputs:
command: "custom"
customCommand: "run test-build -- --publisher $(publisher)"
- task: CopyFiles@2
displayName: "Copy test extensions to build directory"
inputs:
SourceFolder: "$(Build.SourcesDirectory)/dist"
Contents: "*.vsix"
TargetFolder: "$(Agent.BuildDirectory)/extensions/test"
- task: Bash@3
displayName: "Fetch extensions versions and rename vsix"
name: versions
inputs:
targetType: "inline"
script: |
npx gulp ci:azure:get-extensions-version
- task: PublishBuildArtifacts@1
displayName: "Publish artifacts on the build"
inputs:
PathtoPublish: "$(Agent.BuildDirectory)/extensions"
ArtifactName: "extensions"
- stage: run_qa
condition: succeeded()
dependsOn: build
displayName: "Re-publish test extension & Run QA"
jobs:
- job: install_test_extension
displayName: "Install the extension under test"
variables:
publisher: $(SonarSourceITPublisher)
sqExtensionVersion: $[stageDependencies.build.npminstall.outputs['versions.SQ_VERSION']]
scExtensionVersion: $[stageDependencies.build.npminstall.outputs['versions.SC_VERSION']]
itOrg: $(SonarSourceITOrganization)
steps:
- bash: |
echo "##vso[task.setvariable variable=SQ_VERSION;isoutput=true]$(sqExtensionVersion)"
echo "##vso[task.setvariable variable=SC_VERSION;isoutput=true]$(scExtensionVersion)"
name: versions
# Install TFX
- task: TfxInstaller@4
displayName: "Install TFX CLI"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
version: "v0.10.x"
# Publish Extension
- task: DownloadBuildArtifacts@1
displayName: "Download artifacts"
inputs:
buildType: "current"
downloadType: "single"
artifactName: "extensions"
downloadPath: "$(System.ArtifactsDirectory)"
- task: PublishAzureDevOpsExtension@5
displayName: "Publish SonarCloud test extension"
inputs:
connectTo: "AzureRM"
connectedServiceNameAzureRM: "$(MarketplaceARMServiceConnection)"
fileType: "vsix"
vsixFile: "$(System.ArtifactsDirectory)/extensions/test/sonar-scanner-azdo-$(scExtensionVersion)-sonarcloud.vsix"
extensionName: "[Test] SonarCloud ITs"
updateTasksVersion: false
updateTasksId: false
extensionVisibility: "private"
shareWith: "$(itOrg)"
cwd: "$(System.ArtifactsDirectory)"
# Install extension
- task: InstallAzureDevOpsExtension@5
displayName: "Install Test extension in IT org"
inputs:
connectTo: "AzureRM"
connectedServiceNameAzureRM: "$(MarketplaceARMServiceConnection)"
method: "id"
publisherId: "$(publisher)"
extensionId: "sonarcloud-test"
accounts: "https://devops.azure.com/$(itOrg)"
- job: run_its
dependsOn: install_test_extension
displayName: "Run ITs"
variables:
npm_config_cache: $(Pipeline.Workspace)/.npm
steps:
- task: Cache@2
inputs:
key: 'version2 | npm | "$(Agent.OS)" | **/package-lock.json'
restoreKeys: |
npm | "$(Agent.OS)"
path: $(npm_config_cache)
displayName: Cache npm
- task: Npm@1
displayName: "Install all dependencies"
env:
ARTIFACTORY_TOKEN: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
command: "install"
- task: AzureCLI@2
displayName: "Acquire token for integration testing"
inputs:
connectedServiceNameARM: "$(IntegrationTestARMServiceConnection)"
scriptType: "pscore"
scriptLocation: "inlineScript"
useGlobalConfig: true
inlineScript: |
$accessToken = az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query "accessToken" --output tsv
write-host "##vso[task.setsecret]$accessToken"
write-host "##vso[task.setvariable variable=INTEGRATION_TESTING_TOKEN;issecret=true]$accessToken"
- task: Bash@3
displayName: "Run the ITs"
env:
SONARCLOUD_TOKEN: $(SonarCloudToken)
AZURE_TOKEN: $(INTEGRATION_TESTING_TOKEN)
AZURE_BRANCH: $(azureBranch)
inputs:
targetType: "inline"
script: |
npm run test-its
- stage: publish_dogfood
displayName: "Publish dogfood extension"
condition: and(succeeded(), eq(variables['isMain'], true))
jobs:
- job: "publish_dogfood"
variables:
publisher: $(SonarSourceITPublisher)
scExtensionVersion: $[stageDependencies.run_qa.install_test_extension.outputs['versions.SC_VERSION']]
sqExtensionVersion: $[stageDependencies.run_qa.install_test_extension.outputs['versions.SQ_VERSION']]
steps:
- task: TfxInstaller@4
displayName: "Install TFX CLI"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
version: "v0.10.x"
- task: DownloadBuildArtifacts@1
displayName: "Download artifacts"
inputs:
buildType: "current"
downloadType: "single"
artifactName: "extensions"
downloadPath: "$(System.ArtifactsDirectory)"
- task: PublishAzureDevOpsExtension@5
displayName: "Publish SonarCloud dogfood extension"
inputs:
connectTo: "AzureRM"
connectedServiceNameAzureRM: "$(MarketplaceARMServiceConnection)"
fileType: "vsix"
vsixFile: "$(System.ArtifactsDirectory)/extensions/dogfood/sonar-scanner-azdo-$(scExtensionVersion)-sonarcloud.vsix"
extensionName: "[Dogfood] SonarCloud"
extensionId: "sonarcloud-dogfood"
updateTasksVersion: false
updateTasksId: false
extensionVisibility: "private"
shareWith: "sonarsource"
cwd: "$(System.ArtifactsDirectory)"
- task: PublishAzureDevOpsExtension@5
displayName: "Publish SonarQube Server dogfood extension"
inputs:
connectTo: "AzureRM"
connectedServiceNameAzureRM: "$(MarketplaceARMServiceConnection)"
fileType: "vsix"
vsixFile: "$(System.ArtifactsDirectory)/extensions/dogfood/sonar-scanner-azdo-$(sqExtensionVersion)-sonarqube.vsix"
extensionName: "[Dogfood] SonarQube Server"
extensionId: "sonarqube-dogfood"
updateTasksVersion: false
updateTasksId: false
extensionVisibility: "private"
shareWith: "sonarsource"
cwd: "$(System.ArtifactsDirectory)"