-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathazure-pipelines.yml
231 lines (209 loc) · 8.42 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
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
# 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')]
stages:
- stage: build
displayName: "Build:"
jobs:
- job: npminstall
displayName: "NPM Install, CI and Build"
variables:
publisher: $(SonarSourceITPublisher)
steps:
- task: Bash@3
displayName: "Update NPM"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
targetType: "inline"
script: |
sudo npm i -g npm@10
- task: Bash@3
displayName: "Install all extension dependencies"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
filePath: "scripts/install.sh"
- 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 taks 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: "run_qa"
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=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@4
displayName: "Publish SonarCloud test extension"
inputs:
connectTo: "VsTeam"
connectedServiceName: "AzDo Extension - Marketplace - IntegrationTests"
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@4
displayName: "Install extension in IT org"
inputs:
connectTo: "VsTeam"
connectedServiceName: "AzDo Extension - Marketplace - IntegrationTests"
method: "id"
publisherId: "$(publisher)"
extensionId: "sonarcloud-test"
accounts: "https://devops.azure.com/$(itOrg)"
# Run ITs
- task: Bash@3
displayName: "Install all dependencies"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
filePath: "scripts/install.sh"
- task: Bash@3
displayName: "Install all extension dependencies"
env:
NPM_CONFIG_//repox.jfrog.io/artifactory/api/npm/:_authToken: $(ARTIFACTORY_PRIVATE_READER_ACCESS_TOKEN)
inputs:
filePath: "scripts/install.sh"
- task: Bash@3
displayName: "Run the ITs"
env:
SONARCLOUD_TOKEN: $(SonarCloudToken)
AZURE_TOKEN: $(SonarSourceITOrganizationPAT)
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.run_qa.outputs['versions.SC_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@4
displayName: "Publish SonarCloud dogfood extension"
inputs:
connectTo: "VsTeam"
connectedServiceName: "AzDO Extension - Marketplace - Dogfood"
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)"