Restore pipeline output variable for Agent OS name (#1709)

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-02-22 13:47:08 -08:00 committed by GitHub
parent 0dfe2f498d
commit 7e22da08b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -13,4 +13,4 @@ steps:
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: ${{ parameters.ScriptDirectory }}/Verify-AgentOS.ps1
arguments: >
-AgentImage ${{ parameters.AgentImage }}
-AgentImage "${{ parameters.AgentImage }}"

View File

@ -8,6 +8,14 @@ function Throw-InvalidOperatingSystem {
throw "Invalid operating system detected. Operating system was: $([System.Runtime.InteropServices.RuntimeInformation]::OSDescription), expected image was: $AgentImage"
}
if ($AgentImage -match "windows|win|MMS2019" -and !$IsWindows) { Throw-InvalidOperatingSystem }
if ($AgentImage -match "ubuntu" -and !$IsLinux) { Throw-InvalidOperatingSystem }
if ($AgentImage -match "macos" -and !$IsMacOs) { Throw-InvalidOperatingSystem }
if ($IsWindows -and $AgentImage -match "windows|win|MMS2019") {
$osName = "Windows"
} elseif ($IsLinux -and $AgentImage -match "ubuntu") {
$osName = "Linux"
} elseif ($IsMacOs -and $AgentImage -match "macos") {
$osName = "macOS"
} else {
Throw-InvalidOperatingSystem
}
Write-Host "##vso[task.setvariable variable=OSName]$osName"