Skip to content
Merged
Changes from 1 commit
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
Next Next commit
[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: #8294

Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>
  • Loading branch information
ilia-shipitsin and jessehouwing committed Sep 28, 2023
commit e3eb1f4922b1991eebdc7678fec5750fae10dab8
36 changes: 35 additions & 1 deletion images/win/scripts/Installers/Install-AzureDevOpsCli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@
## Desc: Install Azure DevOps CLI
################################################################################

# Store azure-devops-cli cache outside of the provisioning user's profile
[Environment]::SetEnvironmentVariable('AZURE_DEVOPS_EXT_CONFIG_DIR', $azureDevOpsCliConfigPath, [System.EnvironmentVariableTarget]::Machine)
# make variable to be available in the current session
${env:AZURE_DEVOPS_EXT_CONFIG_DIR} = $azureDevOpsCliConfigPath

$azureDevOpsCliCachePath = Join-Path $azureDevOpsCliConfigPath 'cache'
$null = New-Item -ItemType 'Directory' -Path $azureDevOpsCliCachePath

[Environment]::SetEnvironmentVariable('AZURE_DEVOPS_CACHE_DIR', $azureDevOpsCliCachePath, [System.EnvironmentVariableTarget]::Machine)
# make variable to be available in the current session
${env:AZURE_DEVOPS_CACHE_DIR} = $azureDevOpsCliCachePath

az extension add -n azure-devops
if ($LASTEXITCODE -ne 0)
{
throw "Command 'az extension add -n azure-devops' failed"
}

# Warm-up Azure DevOps CLI

Write-Host "Warmup 'az-devops'"
@('devops', 'pipelines', 'boards', 'repos', 'artifacts') | ForEach-Object {

az $_ --help
if ($LASTEXITCODE -ne 0)
{
throw "Command 'az $_ --help' failed"
}

}

# calling az devops login to force it to install `keyring`. Login will actually fail, redirecting error to null
Write-Host 'fake token' | az devops login | Out-Null
# calling az devops logout to be sure no credentials remain.
az devops logout | out-null

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