Skip to content

Commit 09b922a

Browse files
Fix the npm registry issue in release pipeline (#670)
* fix the npm registry issue in release pipeline * add network polices * remove npm upgrade * updrage npm only if is not installed
1 parent 1cd5f14 commit 09b922a

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

.azure-pipelines/azure-pipelines-release.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ resources:
1717
extends:
1818
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
1919
parameters:
20+
settings:
21+
networkIsolationPolicy: Preferred,CFSClean,NodeTool
2022
sdl:
2123
sbom:
2224
enabled: false
@@ -40,15 +42,22 @@ extends:
4042
dependsOn: BuildAndTest
4143
condition: and(succeeded(), in(variables['build.reason'], 'IndividualCI', 'BatchedCI', 'Manual'), eq(variables['build.sourcebranchname'], 'master'))
4244
steps:
43-
- task: NodeTool@0
45+
- task: UseNode@1
4446
inputs:
45-
versionSpec: '16.x'
47+
version: '16.x'
4648
displayName: Install node
47-
- script: npm install -g npm@8
48-
displayName: Upgrade npm
4949
- task: NpmAuthenticate@0
5050
inputs:
5151
workingFile: .npmrc
52+
- script: |
53+
CURRENT_MAJOR=$(npm --version | cut -d. -f1)
54+
if [ "$CURRENT_MAJOR" -lt 8 ]; then
55+
echo "Required npm 8 not present (current: $CURRENT_MAJOR). Installing..."
56+
npm install -g npm@8 --userconfig=$(Build.SourcesDirectory)/.npmrc
57+
else
58+
echo "Required npm 8 is already present (current: $CURRENT_MAJOR). Skipping."
59+
fi
60+
displayName: Upgrade npm (if needed)
5261
- script: npm install
5362
displayName: npm install
5463
- script: npm run build
@@ -84,9 +93,9 @@ extends:
8493
steps:
8594
- checkout: self
8695
clean: true
87-
- task: NodeTool@0
96+
- task: UseNode@1
8897
inputs:
89-
versionSpec: 16.x
98+
version: 16.x
9099
displayName: Install node
91100
- task: NpmAuthenticate@0
92101
inputs:

.azure-pipelines/build-template.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,22 @@ jobs:
2525
strategy:
2626
matrix: ${{ parameters.nodeVersions }}
2727
steps:
28-
- task: NodeTool@0
28+
- task: UseNode@1
2929
inputs:
30-
versionSpec: $(versionSpec)
30+
version: $(versionSpec)
3131
displayName: Install node
32-
- script: npm install -g npm@$(npmVersion)
33-
displayName: Upgrade npm
3432
- task: NpmAuthenticate@0
3533
inputs:
3634
workingFile: .npmrc
35+
- script: |
36+
CURRENT_MAJOR=$(npm --version | cut -d. -f1)
37+
if [ "$CURRENT_MAJOR" -lt "$(npmVersion)" ]; then
38+
echo "Required npm $(npmVersion) not present (current: $CURRENT_MAJOR). Installing..."
39+
npm install -g npm@$(npmVersion) --userconfig=$(Build.SourcesDirectory)/.npmrc
40+
else
41+
echo "Required npm $(npmVersion) is already present (current: $CURRENT_MAJOR). Skipping."
42+
fi
43+
displayName: Upgrade npm (if needed)
3744
- script: npm install
3845
displayName: npm install
3946
- script: npm run build

0 commit comments

Comments
 (0)