Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/azure-pipelines/linux/product-build-linux.yml
3520 views
1
parameters:
2
- name: VSCODE_QUALITY
3
type: string
4
- name: VSCODE_ARCH
5
type: string
6
- name: VSCODE_CIBUILD
7
type: boolean
8
- name: VSCODE_BUILD_LINUX_SNAP
9
type: boolean
10
default: false
11
- name: VSCODE_RUN_ELECTRON_TESTS
12
type: boolean
13
default: false
14
- name: VSCODE_RUN_BROWSER_TESTS
15
type: boolean
16
default: false
17
- name: VSCODE_RUN_REMOTE_TESTS
18
type: boolean
19
default: false
20
- name: VSCODE_TEST_ARTIFACT_NAME
21
type: string
22
default: ""
23
24
steps:
25
- template: ../common/checkout.yml@self
26
27
- task: NodeTool@0
28
inputs:
29
versionSource: fromFile
30
versionFilePath: .nvmrc
31
32
- template: ../distro/download-distro.yml@self
33
34
- task: AzureKeyVault@2
35
displayName: "Azure Key Vault: Get Secrets"
36
inputs:
37
azureSubscription: vscode
38
KeyVaultName: vscode-build-secrets
39
SecretsFilter: "github-distro-mixin-password"
40
41
- task: DownloadPipelineArtifact@2
42
inputs:
43
artifact: Compilation
44
path: $(Build.ArtifactStagingDirectory)
45
displayName: Download compilation output
46
47
- script: tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz
48
displayName: Extract compilation output
49
50
- script: |
51
set -e
52
# Start X server
53
./build/azure-pipelines/linux/apt-retry.sh sudo apt-get update
54
./build/azure-pipelines/linux/apt-retry.sh sudo apt-get install -y pkg-config \
55
xvfb \
56
libgtk-3-0 \
57
libxkbfile-dev \
58
libkrb5-dev \
59
libgbm1 \
60
rpm
61
sudo cp build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb
62
sudo chmod +x /etc/init.d/xvfb
63
sudo update-rc.d xvfb defaults
64
sudo service xvfb start
65
displayName: Setup system services
66
67
- script: node build/setup-npm-registry.js $NPM_REGISTRY
68
condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))
69
displayName: Setup NPM Registry
70
71
- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.js linux $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash
72
displayName: Prepare node_modules cache key
73
74
- task: Cache@2
75
inputs:
76
key: '"node_modules" | .build/packagelockhash'
77
path: .build/node_modules_cache
78
cacheHitVar: NODE_MODULES_RESTORED
79
displayName: Restore node_modules cache
80
81
- script: tar -xzf .build/node_modules_cache/cache.tgz
82
condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))
83
displayName: Extract node_modules cache
84
85
- script: |
86
set -e
87
# Set the private NPM registry to the global npmrc file
88
# so that authentication works for subfolders like build/, remote/, extensions/ etc
89
# which does not have their own .npmrc file
90
npm config set registry "$NPM_REGISTRY"
91
echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"
92
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
93
displayName: Setup NPM
94
95
- task: npmAuthenticate@0
96
inputs:
97
workingFile: $(NPMRC_PATH)
98
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))
99
displayName: Setup NPM Authentication
100
101
- script: |
102
set -e
103
104
for i in {1..5}; do # try 5 times
105
npm ci && break
106
if [ $i -eq 5 ]; then
107
echo "Npm install failed too many times" >&2
108
exit 1
109
fi
110
echo "Npm install failed $i, trying again..."
111
done
112
workingDirectory: build
113
env:
114
GITHUB_TOKEN: "$(github-distro-mixin-password)"
115
displayName: Install build dependencies
116
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
117
118
# Step will be used by both verify glibcxx version for remote server and building rpm package,
119
# hence avoid adding it behind NODE_MODULES_RESTORED condition.
120
- script: |
121
set -e
122
SYSROOT_ARCH=$VSCODE_ARCH
123
if [ "$SYSROOT_ARCH" == "x64" ]; then
124
SYSROOT_ARCH="amd64"
125
fi
126
export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-8.5.0
127
SYSROOT_ARCH="$SYSROOT_ARCH" VSCODE_SYSROOT_PREFIX="-glibc-2.28-gcc-8.5.0" node -e '(async () => { const { getVSCodeSysroot } = require("./build/linux/debian/install-sysroot.js"); await getVSCodeSysroot(process.env["SYSROOT_ARCH"]); })()'
128
env:
129
VSCODE_ARCH: $(VSCODE_ARCH)
130
GITHUB_TOKEN: "$(github-distro-mixin-password)"
131
displayName: Download vscode sysroots
132
133
- script: |
134
set -e
135
136
source ./build/azure-pipelines/linux/setup-env.sh
137
138
for i in {1..5}; do # try 5 times
139
npm ci && break
140
if [ $i -eq 5 ]; then
141
echo "Npm install failed too many times" >&2
142
exit 1
143
fi
144
echo "Npm install failed $i, trying again..."
145
done
146
env:
147
npm_config_arch: $(NPM_ARCH)
148
VSCODE_ARCH: $(VSCODE_ARCH)
149
ELECTRON_SKIP_BINARY_DOWNLOAD: 1
150
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
151
GITHUB_TOKEN: "$(github-distro-mixin-password)"
152
displayName: Install dependencies
153
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
154
155
- script: node build/azure-pipelines/distro/mixin-npm
156
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
157
displayName: Mixin distro node modules
158
159
- script: |
160
set -e
161
node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt
162
mkdir -p .build/node_modules_cache
163
tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt
164
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
165
displayName: Create node_modules archive
166
167
- script: node build/azure-pipelines/distro/mixin-quality
168
displayName: Mixin distro quality
169
170
- template: ../common/install-builtin-extensions.yml@self
171
172
- script: |
173
set -e
174
npm run gulp vscode-linux-$(VSCODE_ARCH)-min-ci
175
ARCHIVE_PATH=".build/linux/client/code-${{ parameters.VSCODE_QUALITY }}-$(VSCODE_ARCH)-$(date +%s).tar.gz"
176
mkdir -p $(dirname $ARCHIVE_PATH)
177
echo "##vso[task.setvariable variable=CLIENT_PATH]$ARCHIVE_PATH"
178
env:
179
GITHUB_TOKEN: "$(github-distro-mixin-password)"
180
displayName: Build client
181
182
- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:
183
- task: DownloadPipelineArtifact@2
184
inputs:
185
artifact: $(ARTIFACT_PREFIX)vscode_cli_linux_$(VSCODE_ARCH)_cli
186
patterns: "**"
187
path: $(Build.ArtifactStagingDirectory)/cli
188
displayName: Download VS Code CLI
189
190
- script: |
191
set -e
192
tar -xzvf $(Build.ArtifactStagingDirectory)/cli/*.tar.gz -C $(Build.ArtifactStagingDirectory)/cli
193
CLI_APP_NAME=$(node -p "require(\"$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/resources/app/product.json\").tunnelApplicationName")
194
APP_NAME=$(node -p "require(\"$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/resources/app/product.json\").applicationName")
195
mv $(Build.ArtifactStagingDirectory)/cli/$APP_NAME $(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/bin/$CLI_APP_NAME
196
displayName: Mix in CLI
197
198
- script: |
199
set -e
200
tar -czf $CLIENT_PATH -C .. VSCode-linux-$(VSCODE_ARCH)
201
env:
202
GITHUB_TOKEN: "$(github-distro-mixin-password)"
203
displayName: Archive client
204
205
- script: |
206
set -e
207
npm run gulp vscode-reh-linux-$(VSCODE_ARCH)-min-ci
208
mv ../vscode-reh-linux-$(VSCODE_ARCH) ../vscode-server-linux-$(VSCODE_ARCH) # TODO@joaomoreno
209
ARCHIVE_PATH=".build/linux/server/vscode-server-linux-$(VSCODE_ARCH).tar.gz"
210
UNARCHIVE_PATH="`pwd`/../vscode-server-linux-$(VSCODE_ARCH)"
211
mkdir -p $(dirname $ARCHIVE_PATH)
212
tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-linux-$(VSCODE_ARCH)
213
echo "##vso[task.setvariable variable=SERVER_PATH]$ARCHIVE_PATH"
214
echo "##vso[task.setvariable variable=SERVER_UNARCHIVE_PATH]$UNARCHIVE_PATH"
215
env:
216
GITHUB_TOKEN: "$(github-distro-mixin-password)"
217
displayName: Build server
218
219
- script: |
220
set -e
221
npm run gulp vscode-reh-web-linux-$(VSCODE_ARCH)-min-ci
222
mv ../vscode-reh-web-linux-$(VSCODE_ARCH) ../vscode-server-linux-$(VSCODE_ARCH)-web # TODO@joaomoreno
223
ARCHIVE_PATH=".build/linux/web/vscode-server-linux-$(VSCODE_ARCH)-web.tar.gz"
224
mkdir -p $(dirname $ARCHIVE_PATH)
225
tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-linux-$(VSCODE_ARCH)-web
226
echo "##vso[task.setvariable variable=WEB_PATH]$ARCHIVE_PATH"
227
env:
228
GITHUB_TOKEN: "$(github-distro-mixin-password)"
229
displayName: Build server (web)
230
231
- ${{ if or(eq(parameters.VSCODE_ARCH, 'x64'), eq(parameters.VSCODE_ARCH, 'arm64')) }}:
232
- script: |
233
set -e
234
235
EXPECTED_GLIBC_VERSION="2.28" \
236
EXPECTED_GLIBCXX_VERSION="3.4.25" \
237
VSCODE_SYSROOT_DIR="$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-8.5.0" \
238
./build/azure-pipelines/linux/verify-glibc-requirements.sh
239
env:
240
SEARCH_PATH: $(SERVER_UNARCHIVE_PATH)
241
npm_config_arch: $(NPM_ARCH)
242
VSCODE_ARCH: $(VSCODE_ARCH)
243
displayName: Check GLIBC and GLIBCXX dependencies in server archive
244
245
- ${{ else }}:
246
- script: |
247
set -e
248
249
EXPECTED_GLIBC_VERSION="2.28" \
250
EXPECTED_GLIBCXX_VERSION="3.4.26" \
251
VSCODE_SYSROOT_DIR="$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-8.5.0" \
252
./build/azure-pipelines/linux/verify-glibc-requirements.sh
253
env:
254
SEARCH_PATH: $(SERVER_UNARCHIVE_PATH)
255
npm_config_arch: $(NPM_ARCH)
256
VSCODE_ARCH: $(VSCODE_ARCH)
257
displayName: Check GLIBC and GLIBCXX dependencies in server archive
258
259
- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:
260
- script: |
261
set -e
262
npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-deb"
263
env:
264
GITHUB_TOKEN: "$(github-distro-mixin-password)"
265
displayName: Prepare deb package
266
267
- script: |
268
set -e
269
npm run gulp "vscode-linux-$(VSCODE_ARCH)-build-deb"
270
file_output=$(file $(ls .build/linux/deb/*/deb/*.deb))
271
if [[ "$file_output" != *"data compression xz"* ]]; then
272
echo "Error: unknown compression. $file_output"
273
exit 1
274
fi
275
echo "##vso[task.setvariable variable=DEB_PATH]$(ls .build/linux/deb/*/deb/*.deb)"
276
displayName: Build deb package
277
278
- script: |
279
set -e
280
TRIPLE=""
281
if [ "$VSCODE_ARCH" == "x64" ]; then
282
TRIPLE="x86_64-linux-gnu"
283
elif [ "$VSCODE_ARCH" == "arm64" ]; then
284
TRIPLE="aarch64-linux-gnu"
285
elif [ "$VSCODE_ARCH" == "armhf" ]; then
286
TRIPLE="arm-rpi-linux-gnueabihf"
287
fi
288
export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-10.5.0
289
export STRIP="$VSCODE_SYSROOT_DIR/$TRIPLE/$TRIPLE/bin/strip"
290
npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-rpm"
291
env:
292
VSCODE_ARCH: $(VSCODE_ARCH)
293
displayName: Prepare rpm package
294
295
- script: |
296
set -e
297
npm run gulp "vscode-linux-$(VSCODE_ARCH)-build-rpm"
298
echo "##vso[task.setvariable variable=RPM_PATH]$(ls .build/linux/rpm/*/*.rpm)"
299
displayName: Build rpm package
300
301
- ${{ if eq(parameters.VSCODE_ARCH, 'x64') }}:
302
- task: Docker@1
303
inputs:
304
azureSubscriptionEndpoint: vscode
305
azureContainerRegistry: vscodehub.azurecr.io
306
command: login
307
displayName: Login to Container Registry
308
309
- ${{ if eq(parameters.VSCODE_BUILD_LINUX_SNAP, true) }}:
310
- script: |
311
set -e
312
npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-snap"
313
sudo -E docker run -e VSCODE_ARCH -e VSCODE_QUALITY -v $(pwd):/work -w /work vscodehub.azurecr.io/vscode-linux-build-agent:snapcraft-x64 /bin/bash -c "./build/azure-pipelines/linux/build-snap.sh"
314
315
SNAP_ROOT="$(pwd)/.build/linux/snap/$(VSCODE_ARCH)"
316
SNAP_EXTRACTED_PATH=$(find $SNAP_ROOT -maxdepth 1 -type d -name 'code-*')
317
SNAP_PATH=$(find $SNAP_ROOT -maxdepth 1 -type f -name '*.snap')
318
319
# SBOM tool doesn't like recursive symlinks
320
sudo find $SNAP_EXTRACTED_PATH -type l -delete
321
322
echo "##vso[task.setvariable variable=SNAP_EXTRACTED_PATH]$SNAP_EXTRACTED_PATH"
323
echo "##vso[task.setvariable variable=SNAP_PATH]$SNAP_PATH"
324
env:
325
VSCODE_ARCH: $(VSCODE_ARCH)
326
displayName: Build snap package
327
328
- task: UseDotNet@2
329
inputs:
330
version: 6.x
331
332
- task: EsrpCodeSigning@5
333
inputs:
334
UseMSIAuthentication: true
335
ConnectedServiceName: vscode-esrp
336
AppRegistrationClientId: $(ESRP_CLIENT_ID)
337
AppRegistrationTenantId: $(ESRP_TENANT_ID)
338
AuthAKVName: vscode-esrp
339
AuthSignCertName: esrp-sign
340
FolderPath: .
341
Pattern: noop
342
displayName: 'Install ESRP Tooling'
343
344
- pwsh: |
345
. build/azure-pipelines/win32/exec.ps1
346
$ErrorActionPreference = "Stop"
347
$EsrpCodeSigningTool = (gci -directory -filter EsrpCodeSigning_* $(Agent.RootDirectory)/_tasks | Select-Object -last 1).FullName
348
$Version = (gci -directory $EsrpCodeSigningTool | Select-Object -last 1).FullName
349
echo "##vso[task.setvariable variable=EsrpCliDllPath]$Version/net6.0/esrpcli.dll"
350
displayName: Find ESRP CLI
351
352
- script: npx deemon --detach --wait node build/azure-pipelines/linux/codesign.js
353
env:
354
EsrpCliDllPath: $(EsrpCliDllPath)
355
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
356
displayName: Codesign deb & rpm
357
358
- ${{ if or(eq(parameters.VSCODE_RUN_ELECTRON_TESTS, true), eq(parameters.VSCODE_RUN_BROWSER_TESTS, true), eq(parameters.VSCODE_RUN_REMOTE_TESTS, true)) }}:
359
- template: product-build-linux-test.yml@self
360
parameters:
361
VSCODE_RUN_ELECTRON_TESTS: ${{ parameters.VSCODE_RUN_ELECTRON_TESTS }}
362
VSCODE_RUN_BROWSER_TESTS: ${{ parameters.VSCODE_RUN_BROWSER_TESTS }}
363
VSCODE_RUN_REMOTE_TESTS: ${{ parameters.VSCODE_RUN_REMOTE_TESTS }}
364
VSCODE_TEST_ARTIFACT_NAME: ${{ parameters.VSCODE_TEST_ARTIFACT_NAME }}
365
366
- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:
367
- script: npx deemon --attach node build/azure-pipelines/linux/codesign.js
368
condition: succeededOrFailed()
369
displayName: "✍️ Post-job: Codesign deb & rpm"
370
371
- script: echo "##vso[task.setvariable variable=ARTIFACT_PREFIX]attempt$(System.JobAttempt)_"
372
condition: and(succeededOrFailed(), notIn(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues'))
373
displayName: Generate artifact prefix
374
375
- template: ../common/publish-artifact.yml@self
376
parameters:
377
targetPath: $(CLIENT_PATH)
378
artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_archive-unsigned
379
displayName: Publish client archive
380
sbomBuildDropPath: $(Agent.BuildDirectory)/VSCode-linux-$(VSCODE_ARCH)
381
sbomPackageName: "VS Code Linux $(VSCODE_ARCH) (unsigned)"
382
sbomPackageVersion: $(Build.SourceVersion)
383
condition: and(succeededOrFailed(), ne(variables['CLIENT_PATH'], ''))
384
385
- template: ../common/publish-artifact.yml@self
386
parameters:
387
targetPath: $(SERVER_PATH)
388
artifactName: $(ARTIFACT_PREFIX)vscode_server_linux_$(VSCODE_ARCH)_archive-unsigned
389
displayName: Publish server archive
390
sbomBuildDropPath: $(Agent.BuildDirectory)/vscode-server-linux-$(VSCODE_ARCH)
391
sbomPackageName: "VS Code Linux $(VSCODE_ARCH) Server"
392
sbomPackageVersion: $(Build.SourceVersion)
393
condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''))
394
395
- template: ../common/publish-artifact.yml@self
396
parameters:
397
targetPath: $(WEB_PATH)
398
artifactName: $(ARTIFACT_PREFIX)vscode_web_linux_$(VSCODE_ARCH)_archive-unsigned
399
displayName: Publish web server archive
400
sbomBuildDropPath: $(Agent.BuildDirectory)/vscode-server-linux-$(VSCODE_ARCH)-web
401
sbomPackageName: "VS Code Linux $(VSCODE_ARCH) Web"
402
sbomPackageVersion: $(Build.SourceVersion)
403
condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''))
404
405
- template: ../common/publish-artifact.yml@self
406
parameters:
407
targetPath: $(DEB_PATH)
408
artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_deb-package
409
displayName: Publish deb package
410
sbomBuildDropPath: .build/linux/deb
411
sbomPackageName: "VS Code Linux $(VSCODE_ARCH) DEB"
412
sbomPackageVersion: $(Build.SourceVersion)
413
condition: and(succeededOrFailed(), ne(variables['DEB_PATH'], ''))
414
415
- template: ../common/publish-artifact.yml@self
416
parameters:
417
targetPath: $(RPM_PATH)
418
artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_rpm-package
419
displayName: Publish rpm package
420
sbomBuildDropPath: .build/linux/rpm
421
sbomPackageName: "VS Code Linux $(VSCODE_ARCH) RPM"
422
sbomPackageVersion: $(Build.SourceVersion)
423
condition: and(succeededOrFailed(), ne(variables['RPM_PATH'], ''))
424
425
- template: ../common/publish-artifact.yml@self
426
parameters:
427
targetPath: $(SNAP_PATH)
428
artifactName: vscode_client_linux_$(VSCODE_ARCH)_snap
429
displayName: Publish snap package
430
sbomBuildDropPath: $(SNAP_EXTRACTED_PATH)
431
sbomPackageName: "VS Code Linux $(VSCODE_ARCH) SNAP"
432
sbomPackageVersion: $(Build.SourceVersion)
433
condition: and(succeededOrFailed(), ne(variables['SNAP_PATH'], ''))
434
435