Path: blob/main/build/azure-pipelines/linux/product-build-linux.yml
3520 views
parameters:1- name: VSCODE_QUALITY2type: string3- name: VSCODE_ARCH4type: string5- name: VSCODE_CIBUILD6type: boolean7- name: VSCODE_BUILD_LINUX_SNAP8type: boolean9default: false10- name: VSCODE_RUN_ELECTRON_TESTS11type: boolean12default: false13- name: VSCODE_RUN_BROWSER_TESTS14type: boolean15default: false16- name: VSCODE_RUN_REMOTE_TESTS17type: boolean18default: false19- name: VSCODE_TEST_ARTIFACT_NAME20type: string21default: ""2223steps:24- template: ../common/checkout.yml@self2526- task: NodeTool@027inputs:28versionSource: fromFile29versionFilePath: .nvmrc3031- template: ../distro/download-distro.yml@self3233- task: AzureKeyVault@234displayName: "Azure Key Vault: Get Secrets"35inputs:36azureSubscription: vscode37KeyVaultName: vscode-build-secrets38SecretsFilter: "github-distro-mixin-password"3940- task: DownloadPipelineArtifact@241inputs:42artifact: Compilation43path: $(Build.ArtifactStagingDirectory)44displayName: Download compilation output4546- script: tar -xzf $(Build.ArtifactStagingDirectory)/compilation.tar.gz47displayName: Extract compilation output4849- script: |50set -e51# Start X server52./build/azure-pipelines/linux/apt-retry.sh sudo apt-get update53./build/azure-pipelines/linux/apt-retry.sh sudo apt-get install -y pkg-config \54xvfb \55libgtk-3-0 \56libxkbfile-dev \57libkrb5-dev \58libgbm1 \59rpm60sudo cp build/azure-pipelines/linux/xvfb.init /etc/init.d/xvfb61sudo chmod +x /etc/init.d/xvfb62sudo update-rc.d xvfb defaults63sudo service xvfb start64displayName: Setup system services6566- script: node build/setup-npm-registry.js $NPM_REGISTRY67condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none'))68displayName: Setup NPM Registry6970- script: mkdir -p .build && node build/azure-pipelines/common/computeNodeModulesCacheKey.js linux $VSCODE_ARCH $(node -p process.arch) > .build/packagelockhash71displayName: Prepare node_modules cache key7273- task: Cache@274inputs:75key: '"node_modules" | .build/packagelockhash'76path: .build/node_modules_cache77cacheHitVar: NODE_MODULES_RESTORED78displayName: Restore node_modules cache7980- script: tar -xzf .build/node_modules_cache/cache.tgz81condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true'))82displayName: Extract node_modules cache8384- script: |85set -e86# Set the private NPM registry to the global npmrc file87# so that authentication works for subfolders like build/, remote/, extensions/ etc88# which does not have their own .npmrc file89npm config set registry "$NPM_REGISTRY"90echo "##vso[task.setvariable variable=NPMRC_PATH]$(npm config get userconfig)"91condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))92displayName: Setup NPM9394- task: npmAuthenticate@095inputs:96workingFile: $(NPMRC_PATH)97condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none'))98displayName: Setup NPM Authentication99100- script: |101set -e102103for i in {1..5}; do # try 5 times104npm ci && break105if [ $i -eq 5 ]; then106echo "Npm install failed too many times" >&2107exit 1108fi109echo "Npm install failed $i, trying again..."110done111workingDirectory: build112env:113GITHUB_TOKEN: "$(github-distro-mixin-password)"114displayName: Install build dependencies115condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))116117# Step will be used by both verify glibcxx version for remote server and building rpm package,118# hence avoid adding it behind NODE_MODULES_RESTORED condition.119- script: |120set -e121SYSROOT_ARCH=$VSCODE_ARCH122if [ "$SYSROOT_ARCH" == "x64" ]; then123SYSROOT_ARCH="amd64"124fi125export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-8.5.0126SYSROOT_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"]); })()'127env:128VSCODE_ARCH: $(VSCODE_ARCH)129GITHUB_TOKEN: "$(github-distro-mixin-password)"130displayName: Download vscode sysroots131132- script: |133set -e134135source ./build/azure-pipelines/linux/setup-env.sh136137for i in {1..5}; do # try 5 times138npm ci && break139if [ $i -eq 5 ]; then140echo "Npm install failed too many times" >&2141exit 1142fi143echo "Npm install failed $i, trying again..."144done145env:146npm_config_arch: $(NPM_ARCH)147VSCODE_ARCH: $(VSCODE_ARCH)148ELECTRON_SKIP_BINARY_DOWNLOAD: 1149PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1150GITHUB_TOKEN: "$(github-distro-mixin-password)"151displayName: Install dependencies152condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))153154- script: node build/azure-pipelines/distro/mixin-npm155condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))156displayName: Mixin distro node modules157158- script: |159set -e160node build/azure-pipelines/common/listNodeModules.js .build/node_modules_list.txt161mkdir -p .build/node_modules_cache162tar -czf .build/node_modules_cache/cache.tgz --files-from .build/node_modules_list.txt163condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))164displayName: Create node_modules archive165166- script: node build/azure-pipelines/distro/mixin-quality167displayName: Mixin distro quality168169- template: ../common/install-builtin-extensions.yml@self170171- script: |172set -e173npm run gulp vscode-linux-$(VSCODE_ARCH)-min-ci174ARCHIVE_PATH=".build/linux/client/code-${{ parameters.VSCODE_QUALITY }}-$(VSCODE_ARCH)-$(date +%s).tar.gz"175mkdir -p $(dirname $ARCHIVE_PATH)176echo "##vso[task.setvariable variable=CLIENT_PATH]$ARCHIVE_PATH"177env:178GITHUB_TOKEN: "$(github-distro-mixin-password)"179displayName: Build client180181- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:182- task: DownloadPipelineArtifact@2183inputs:184artifact: $(ARTIFACT_PREFIX)vscode_cli_linux_$(VSCODE_ARCH)_cli185patterns: "**"186path: $(Build.ArtifactStagingDirectory)/cli187displayName: Download VS Code CLI188189- script: |190set -e191tar -xzvf $(Build.ArtifactStagingDirectory)/cli/*.tar.gz -C $(Build.ArtifactStagingDirectory)/cli192CLI_APP_NAME=$(node -p "require(\"$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/resources/app/product.json\").tunnelApplicationName")193APP_NAME=$(node -p "require(\"$(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/resources/app/product.json\").applicationName")194mv $(Build.ArtifactStagingDirectory)/cli/$APP_NAME $(agent.builddirectory)/VSCode-linux-$(VSCODE_ARCH)/bin/$CLI_APP_NAME195displayName: Mix in CLI196197- script: |198set -e199tar -czf $CLIENT_PATH -C .. VSCode-linux-$(VSCODE_ARCH)200env:201GITHUB_TOKEN: "$(github-distro-mixin-password)"202displayName: Archive client203204- script: |205set -e206npm run gulp vscode-reh-linux-$(VSCODE_ARCH)-min-ci207mv ../vscode-reh-linux-$(VSCODE_ARCH) ../vscode-server-linux-$(VSCODE_ARCH) # TODO@joaomoreno208ARCHIVE_PATH=".build/linux/server/vscode-server-linux-$(VSCODE_ARCH).tar.gz"209UNARCHIVE_PATH="`pwd`/../vscode-server-linux-$(VSCODE_ARCH)"210mkdir -p $(dirname $ARCHIVE_PATH)211tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-linux-$(VSCODE_ARCH)212echo "##vso[task.setvariable variable=SERVER_PATH]$ARCHIVE_PATH"213echo "##vso[task.setvariable variable=SERVER_UNARCHIVE_PATH]$UNARCHIVE_PATH"214env:215GITHUB_TOKEN: "$(github-distro-mixin-password)"216displayName: Build server217218- script: |219set -e220npm run gulp vscode-reh-web-linux-$(VSCODE_ARCH)-min-ci221mv ../vscode-reh-web-linux-$(VSCODE_ARCH) ../vscode-server-linux-$(VSCODE_ARCH)-web # TODO@joaomoreno222ARCHIVE_PATH=".build/linux/web/vscode-server-linux-$(VSCODE_ARCH)-web.tar.gz"223mkdir -p $(dirname $ARCHIVE_PATH)224tar --owner=0 --group=0 -czf $ARCHIVE_PATH -C .. vscode-server-linux-$(VSCODE_ARCH)-web225echo "##vso[task.setvariable variable=WEB_PATH]$ARCHIVE_PATH"226env:227GITHUB_TOKEN: "$(github-distro-mixin-password)"228displayName: Build server (web)229230- ${{ if or(eq(parameters.VSCODE_ARCH, 'x64'), eq(parameters.VSCODE_ARCH, 'arm64')) }}:231- script: |232set -e233234EXPECTED_GLIBC_VERSION="2.28" \235EXPECTED_GLIBCXX_VERSION="3.4.25" \236VSCODE_SYSROOT_DIR="$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-8.5.0" \237./build/azure-pipelines/linux/verify-glibc-requirements.sh238env:239SEARCH_PATH: $(SERVER_UNARCHIVE_PATH)240npm_config_arch: $(NPM_ARCH)241VSCODE_ARCH: $(VSCODE_ARCH)242displayName: Check GLIBC and GLIBCXX dependencies in server archive243244- ${{ else }}:245- script: |246set -e247248EXPECTED_GLIBC_VERSION="2.28" \249EXPECTED_GLIBCXX_VERSION="3.4.26" \250VSCODE_SYSROOT_DIR="$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-8.5.0" \251./build/azure-pipelines/linux/verify-glibc-requirements.sh252env:253SEARCH_PATH: $(SERVER_UNARCHIVE_PATH)254npm_config_arch: $(NPM_ARCH)255VSCODE_ARCH: $(VSCODE_ARCH)256displayName: Check GLIBC and GLIBCXX dependencies in server archive257258- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:259- script: |260set -e261npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-deb"262env:263GITHUB_TOKEN: "$(github-distro-mixin-password)"264displayName: Prepare deb package265266- script: |267set -e268npm run gulp "vscode-linux-$(VSCODE_ARCH)-build-deb"269file_output=$(file $(ls .build/linux/deb/*/deb/*.deb))270if [[ "$file_output" != *"data compression xz"* ]]; then271echo "Error: unknown compression. $file_output"272exit 1273fi274echo "##vso[task.setvariable variable=DEB_PATH]$(ls .build/linux/deb/*/deb/*.deb)"275displayName: Build deb package276277- script: |278set -e279TRIPLE=""280if [ "$VSCODE_ARCH" == "x64" ]; then281TRIPLE="x86_64-linux-gnu"282elif [ "$VSCODE_ARCH" == "arm64" ]; then283TRIPLE="aarch64-linux-gnu"284elif [ "$VSCODE_ARCH" == "armhf" ]; then285TRIPLE="arm-rpi-linux-gnueabihf"286fi287export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots/glibc-2.28-gcc-10.5.0288export STRIP="$VSCODE_SYSROOT_DIR/$TRIPLE/$TRIPLE/bin/strip"289npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-rpm"290env:291VSCODE_ARCH: $(VSCODE_ARCH)292displayName: Prepare rpm package293294- script: |295set -e296npm run gulp "vscode-linux-$(VSCODE_ARCH)-build-rpm"297echo "##vso[task.setvariable variable=RPM_PATH]$(ls .build/linux/rpm/*/*.rpm)"298displayName: Build rpm package299300- ${{ if eq(parameters.VSCODE_ARCH, 'x64') }}:301- task: Docker@1302inputs:303azureSubscriptionEndpoint: vscode304azureContainerRegistry: vscodehub.azurecr.io305command: login306displayName: Login to Container Registry307308- ${{ if eq(parameters.VSCODE_BUILD_LINUX_SNAP, true) }}:309- script: |310set -e311npm run gulp "vscode-linux-$(VSCODE_ARCH)-prepare-snap"312sudo -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"313314SNAP_ROOT="$(pwd)/.build/linux/snap/$(VSCODE_ARCH)"315SNAP_EXTRACTED_PATH=$(find $SNAP_ROOT -maxdepth 1 -type d -name 'code-*')316SNAP_PATH=$(find $SNAP_ROOT -maxdepth 1 -type f -name '*.snap')317318# SBOM tool doesn't like recursive symlinks319sudo find $SNAP_EXTRACTED_PATH -type l -delete320321echo "##vso[task.setvariable variable=SNAP_EXTRACTED_PATH]$SNAP_EXTRACTED_PATH"322echo "##vso[task.setvariable variable=SNAP_PATH]$SNAP_PATH"323env:324VSCODE_ARCH: $(VSCODE_ARCH)325displayName: Build snap package326327- task: UseDotNet@2328inputs:329version: 6.x330331- task: EsrpCodeSigning@5332inputs:333UseMSIAuthentication: true334ConnectedServiceName: vscode-esrp335AppRegistrationClientId: $(ESRP_CLIENT_ID)336AppRegistrationTenantId: $(ESRP_TENANT_ID)337AuthAKVName: vscode-esrp338AuthSignCertName: esrp-sign339FolderPath: .340Pattern: noop341displayName: 'Install ESRP Tooling'342343- pwsh: |344. build/azure-pipelines/win32/exec.ps1345$ErrorActionPreference = "Stop"346$EsrpCodeSigningTool = (gci -directory -filter EsrpCodeSigning_* $(Agent.RootDirectory)/_tasks | Select-Object -last 1).FullName347$Version = (gci -directory $EsrpCodeSigningTool | Select-Object -last 1).FullName348echo "##vso[task.setvariable variable=EsrpCliDllPath]$Version/net6.0/esrpcli.dll"349displayName: Find ESRP CLI350351- script: npx deemon --detach --wait node build/azure-pipelines/linux/codesign.js352env:353EsrpCliDllPath: $(EsrpCliDllPath)354SYSTEM_ACCESSTOKEN: $(System.AccessToken)355displayName: ✍️ Codesign deb & rpm356357- ${{ if or(eq(parameters.VSCODE_RUN_ELECTRON_TESTS, true), eq(parameters.VSCODE_RUN_BROWSER_TESTS, true), eq(parameters.VSCODE_RUN_REMOTE_TESTS, true)) }}:358- template: product-build-linux-test.yml@self359parameters:360VSCODE_RUN_ELECTRON_TESTS: ${{ parameters.VSCODE_RUN_ELECTRON_TESTS }}361VSCODE_RUN_BROWSER_TESTS: ${{ parameters.VSCODE_RUN_BROWSER_TESTS }}362VSCODE_RUN_REMOTE_TESTS: ${{ parameters.VSCODE_RUN_REMOTE_TESTS }}363VSCODE_TEST_ARTIFACT_NAME: ${{ parameters.VSCODE_TEST_ARTIFACT_NAME }}364365- ${{ if ne(parameters.VSCODE_CIBUILD, true) }}:366- script: npx deemon --attach node build/azure-pipelines/linux/codesign.js367condition: succeededOrFailed()368displayName: "✍️ Post-job: Codesign deb & rpm"369370- script: echo "##vso[task.setvariable variable=ARTIFACT_PREFIX]attempt$(System.JobAttempt)_"371condition: and(succeededOrFailed(), notIn(variables['Agent.JobStatus'], 'Succeeded', 'SucceededWithIssues'))372displayName: Generate artifact prefix373374- template: ../common/publish-artifact.yml@self375parameters:376targetPath: $(CLIENT_PATH)377artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_archive-unsigned378displayName: Publish client archive379sbomBuildDropPath: $(Agent.BuildDirectory)/VSCode-linux-$(VSCODE_ARCH)380sbomPackageName: "VS Code Linux $(VSCODE_ARCH) (unsigned)"381sbomPackageVersion: $(Build.SourceVersion)382condition: and(succeededOrFailed(), ne(variables['CLIENT_PATH'], ''))383384- template: ../common/publish-artifact.yml@self385parameters:386targetPath: $(SERVER_PATH)387artifactName: $(ARTIFACT_PREFIX)vscode_server_linux_$(VSCODE_ARCH)_archive-unsigned388displayName: Publish server archive389sbomBuildDropPath: $(Agent.BuildDirectory)/vscode-server-linux-$(VSCODE_ARCH)390sbomPackageName: "VS Code Linux $(VSCODE_ARCH) Server"391sbomPackageVersion: $(Build.SourceVersion)392condition: and(succeededOrFailed(), ne(variables['SERVER_PATH'], ''))393394- template: ../common/publish-artifact.yml@self395parameters:396targetPath: $(WEB_PATH)397artifactName: $(ARTIFACT_PREFIX)vscode_web_linux_$(VSCODE_ARCH)_archive-unsigned398displayName: Publish web server archive399sbomBuildDropPath: $(Agent.BuildDirectory)/vscode-server-linux-$(VSCODE_ARCH)-web400sbomPackageName: "VS Code Linux $(VSCODE_ARCH) Web"401sbomPackageVersion: $(Build.SourceVersion)402condition: and(succeededOrFailed(), ne(variables['WEB_PATH'], ''))403404- template: ../common/publish-artifact.yml@self405parameters:406targetPath: $(DEB_PATH)407artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_deb-package408displayName: Publish deb package409sbomBuildDropPath: .build/linux/deb410sbomPackageName: "VS Code Linux $(VSCODE_ARCH) DEB"411sbomPackageVersion: $(Build.SourceVersion)412condition: and(succeededOrFailed(), ne(variables['DEB_PATH'], ''))413414- template: ../common/publish-artifact.yml@self415parameters:416targetPath: $(RPM_PATH)417artifactName: $(ARTIFACT_PREFIX)vscode_client_linux_$(VSCODE_ARCH)_rpm-package418displayName: Publish rpm package419sbomBuildDropPath: .build/linux/rpm420sbomPackageName: "VS Code Linux $(VSCODE_ARCH) RPM"421sbomPackageVersion: $(Build.SourceVersion)422condition: and(succeededOrFailed(), ne(variables['RPM_PATH'], ''))423424- template: ../common/publish-artifact.yml@self425parameters:426targetPath: $(SNAP_PATH)427artifactName: vscode_client_linux_$(VSCODE_ARCH)_snap428displayName: Publish snap package429sbomBuildDropPath: $(SNAP_EXTRACTED_PATH)430sbomPackageName: "VS Code Linux $(VSCODE_ARCH) SNAP"431sbomPackageVersion: $(Build.SourceVersion)432condition: and(succeededOrFailed(), ne(variables['SNAP_PATH'], ''))433434435