Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify node version after install #9498

Merged
merged 3 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions common/smoke-test/smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ jobs:
value: "@{ storageEndpointSuffix = 'core.chinacloudapi.cn'; azureCloud = 'AzureChinaCloud'; }"

steps:
- task: NodeTool@0
displayName: Use Node $(NodeVersion)
inputs:
versionSpec: $(NodeVersion)
- template: ../../eng/pipelines/templates/steps/common.yml

- task: Npm@1
inputs:
Expand Down
9 changes: 1 addition & 8 deletions eng/pipelines/templates/steps/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ steps:

- template: /eng/common/pipelines/templates/steps/verify-agent-os.yml

- task: NodeTool@0
inputs:
versionSpec: "$(NodeVersion)"
displayName: "Use NodeJS $(NodeVersion)"

- script: |
node --version && npm --version
displayName: Node versions
- template: use-node-version.yml
14 changes: 6 additions & 8 deletions eng/pipelines/templates/steps/use-node-test-version.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
steps:
- task: NodeTool@0
inputs:
versionSpec: $(NodeTestVersion)
displayName: "Use NodeJS $(NodeTestVersion)"
parameters:
NodeTestVersion: $(NodeTestVersion)

- script: |
node --version && npm --version
displayName: Node versions
steps:
- template: use-node-version.yml
parameters:
NodeVersion: $(NodeTestVersion)

# Packages with native dependencies must be reinstalled after changing Node versions
- pwsh: |
Expand Down
24 changes: 24 additions & 0 deletions eng/pipelines/templates/steps/use-node-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
parameters:
NodeVersion: $(NodeVersion)

steps:
- task: NodeTool@0
inputs:
versionSpec: ${{ parameters.NodeVersion }}
displayName: "Use Node ${{ parameters.NodeVersion }}"

- pwsh: |
$expectedVersion = "${{ parameters.NodeVersion }}"
Write-Host "Expected Node Version: $expectedVersion"

$actualVersion = (node --version).Substring(1)
Write-Host "Actual Node Version: $actualVersion"
Write-Host "Actual NPM Version: $(npm --version)"

$expectedMajorVersion = $expectedVersion.Split(".")[0]
$actualMajorVersion = $actualVersion.Split(".")[0]
if ($expectedMajorVersion -ne $actualMajorVersion) {
Write-Host "Error: Expected node version does not match actual node version"
exit 1
}
displayName: "Verify Node Version"