Skip to content

Commit e3eb1f4

Browse files
[windows] warmup "az devops" for the first run
as Jesse Houwing has found "az devops" warms up during first run which takes ~40 sec. warm up is done by running "az devops <subsystem> --help" with config redirected to persistent "C:\" location, also keyring installation requires "fake" login original PR: actions#8294 Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>
1 parent a4234d4 commit e3eb1f4

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

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

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

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

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

0 commit comments

Comments
 (0)