Skip to content

Commit 6f2f889

Browse files
[windows] warmup "az devops" for the first run (#8410)
1 parent 5bb622f commit 6f2f889

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

images/win/scripts/Installers/Install-AzureDevOpsCli.ps1

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,41 @@
33
## Desc: Install Azure DevOps CLI
44
################################################################################
55

6+
$azureDevOpsCliConfigPath = 'C:\azureDevOpsCli'
7+
# Store azure-devops-cli cache outside of the provisioning user's profile
8+
[Environment]::SetEnvironmentVariable('AZURE_DEVOPS_EXT_CONFIG_DIR', $azureDevOpsCliConfigPath, [System.EnvironmentVariableTarget]::Machine)
9+
# make variable to be available in the current session
10+
${env:AZURE_DEVOPS_EXT_CONFIG_DIR} = $azureDevOpsCliConfigPath
11+
12+
$azureDevOpsCliCachePath = Join-Path $azureDevOpsCliConfigPath 'cache'
13+
$null = New-Item -ItemType 'Directory' -Path $azureDevOpsCliCachePath
14+
15+
[Environment]::SetEnvironmentVariable('AZURE_DEVOPS_CACHE_DIR', $azureDevOpsCliCachePath, [System.EnvironmentVariableTarget]::Machine)
16+
# make variable to be available in the current session
17+
${env:AZURE_DEVOPS_CACHE_DIR} = $azureDevOpsCliCachePath
18+
619
az extension add -n azure-devops
20+
if ($LASTEXITCODE -ne 0)
21+
{
22+
throw "Command 'az extension add -n azure-devops' failed"
23+
}
24+
25+
# Warm-up Azure DevOps CLI
26+
27+
Write-Host "Warmup 'az-devops'"
28+
@('devops', 'pipelines', 'boards', 'repos', 'artifacts') | ForEach-Object {
29+
30+
az $_ --help
31+
if ($LASTEXITCODE -ne 0)
32+
{
33+
throw "Command 'az $_ --help' failed"
34+
}
35+
36+
}
37+
38+
# calling az devops login to force it to install `keyring`. Login will actually fail, redirecting error to null
39+
Write-Host 'fake token' | az devops login | Out-Null
40+
# calling az devops logout to be sure no credentials remain.
41+
az devops logout | out-null
742

8-
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Azure DevOps CLI"
43+
Invoke-PesterTests -TestFile 'CLI.Tools' -TestName 'Azure DevOps CLI'

0 commit comments

Comments
 (0)