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+
619az 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