Skip to content

Commit 7ca311e

Browse files
authored
Fix ThreadJob installation error of smoke test (#20867)
* Fix ThreadJob installation error of smoke test * Address review comments
1 parent cf2cba8 commit 7ca311e

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

.azure-pipelines/util/smoke-test-steps.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,6 @@ jobs:
7878
Write-Host "List artifacts..."
7979
Get-ChildItem "$(Pipeline.Workspace)\\LocalRepo\\"
8080
81-
- task: NuGetCommand@2
82-
condition: and(succeeded(), eq('${{ parameters.psVersion }}', '5.1.14'))
83-
displayName: 'Download ThreadJob .nupkg File for PowerShell 5.1.14'
84-
inputs:
85-
command: custom
86-
arguments: 'install ThreadJob -directdownload -packagesavemode nupkg -source https://www.powershellgallery.com/api/v2 -OutputDirectory packages'
87-
8881
- task: NuGetCommand@2
8982
condition: and(succeeded(), eq(variables['GalleryName'], 'LocalRepo'))
9083
displayName: 'Download Previous Az .nupkg Files'

tools/Test/SmokeTest/InstallAzModules.ps1

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ Register-Gallery $gallery $localRepoLocation
4242

4343
Write-Host "Installing Az..."
4444
Install-Module -Name Az -Repository $gallery -Scope CurrentUser -AllowClobber -Force
45-
46-
$file = Get-ChildItem $localRepoLocation | Where-Object {$_.Name -like "ThreadJob*"}
47-
$installedModule = Get-Module -ListAVailable -Name ThreadJob
48-
if ($file -ne $null -and $installedModule -eq $null) {
49-
Write-Host "Install ThreadJob..."
50-
Install-Module -Name ThreadJob -Repository $gallery -Scope CurrentUser -AllowClobber -Force
51-
}
5245

5346
# Check version
5447
Import-Module -MinimumVersion '2.6.0' -Name 'Az' -Force
@@ -61,4 +54,4 @@ Get-Module -Name Az.* -ListAvailable
6154

6255
if (!$azVersion) {
6356
throw "No Az is installed"
64-
}
57+
}

tools/Test/SmokeTest/PrepareRequiredPowershell.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ function Install-PowerShell {
5656
dotnet tool run pwsh -c $command
5757
}
5858
}
59+
60+
#Install ThreadJob for Windows PowerShell
61+
if ($requiredPsVersion -eq $windowsPowershellVersion) {
62+
Write-Host "Install ThreadJob for Windows PowerShell."
63+
$installedModule = Get-Module -ListAVailable -Name ThreadJob
64+
if ($installedModule -eq $null) {
65+
try {
66+
Install-Module -Name ThreadJob -Repository PSGallery -Scope CurrentUser -AllowClobber -Force
67+
Write-Host "Install ThreadJob successfully."
68+
}
69+
catch {
70+
Write-Host "Fail to install ThreadJob from PSGallery."
71+
Write-Host $_
72+
}
73+
}
74+
}
5975
}
6076

6177
# Image "macOS-10.15" preinstalled Az modules

0 commit comments

Comments
 (0)