diff --git a/eng/common/pipelines/templates/steps/verify-agent-os.yml b/eng/common/pipelines/templates/steps/verify-agent-os.yml index 33b7ed2c6e7..5c5fe54c957 100644 --- a/eng/common/pipelines/templates/steps/verify-agent-os.yml +++ b/eng/common/pipelines/templates/steps/verify-agent-os.yml @@ -13,4 +13,4 @@ steps: workingDirectory: $(System.DefaultWorkingDirectory) filePath: ${{ parameters.ScriptDirectory }}/Verify-AgentOS.ps1 arguments: > - -AgentImage ${{ parameters.AgentImage }} \ No newline at end of file + -AgentImage "${{ parameters.AgentImage }}" diff --git a/eng/common/scripts/Verify-AgentOS.ps1 b/eng/common/scripts/Verify-AgentOS.ps1 index 3fd6c7170fb..2a7edc4d05b 100644 --- a/eng/common/scripts/Verify-AgentOS.ps1 +++ b/eng/common/scripts/Verify-AgentOS.ps1 @@ -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 } \ No newline at end of file +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"