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

[windows] warmup "az devops" for the first run #8410

Merged
merged 2 commits into from Sep 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 36 additions & 1 deletion images/win/scripts/Installers/Install-AzureDevOpsCli.ps1
Expand Up @@ -3,6 +3,41 @@
## Desc: Install Azure DevOps CLI
################################################################################

$azureDevOpsCliConfigPath = 'C:\azureDevOpsCli'
# 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'