From 275c501de145b8a40c823f78eec1e969fe87783b Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Fri, 19 Feb 2021 11:18:03 -0500 Subject: [PATCH] Restore pipeline output variable for Agent OS name --- .../pipelines/templates/steps/verify-agent-os.yml | 2 +- eng/common/scripts/Verify-AgentOS.ps1 | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-agent-os.yml b/eng/common/pipelines/templates/steps/verify-agent-os.yml index 33b7ed2c6e..5c5fe54c95 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 3fd6c7170f..2a7edc4d05 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"