From b0da2ea7810b2acb87b5f1374191bddb4067e047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Tue, 1 Nov 2022 07:28:06 -0700 Subject: [PATCH] fix Alpine builds with npm custom registry (#165137) fixes #165135 --- .../linux/product-build-alpine.yml | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/build/azure-pipelines/linux/product-build-alpine.yml b/build/azure-pipelines/linux/product-build-alpine.yml index 2175c76556e74..887d69ed121b5 100644 --- a/build/azure-pipelines/linux/product-build-alpine.yml +++ b/build/azure-pipelines/linux/product-build-alpine.yml @@ -59,6 +59,23 @@ steps: condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none')) displayName: Setup NPM Registry + # In Alpine, we always want to setup and authenticate against the NPM_REGISTRY + # because of the Prebuild step, since it always runs `yarn` from inside an alpine + # container + - script: | + set -e + npm config set registry "$NPM_REGISTRY" --location=project + npm config set always-auth=true --location=project + yarn config set registry "$NPM_REGISTRY" + condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none')) + displayName: Setup NPM & Yarn + + - task: npmAuthenticate@0 + inputs: + workingFile: .npmrc + condition: and(succeeded(), ne(variables['NPM_REGISTRY'], 'none')) + displayName: Setup NPM Authentication + - script: | mkdir -p .build node build/azure-pipelines/common/computeNodeModulesCacheKey.js "alpine" > .build/yarnlockhash @@ -84,20 +101,6 @@ steps: condition: and(succeeded(), eq(variables.NODE_MODULES_RESTORED, 'true')) displayName: Extract node_modules cache - - script: | - set -e - npm config set registry "$NPM_REGISTRY" --location=project - npm config set always-auth=true --location=project - yarn config set registry "$NPM_REGISTRY" - condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none')) - displayName: Setup NPM & Yarn - - - task: npmAuthenticate@0 - inputs: - workingFile: .npmrc - condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'), ne(variables['NPM_REGISTRY'], 'none')) - displayName: Setup NPM Authentication - - script: | set -e for i in {1..3}; do # try 3 times