Skip to content

Commit

Permalink
Restore pipeline output variable for Agent OS name (#1709)
Browse files Browse the repository at this point in the history
Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
  • Loading branch information
azure-sdk and benbp authored Feb 22, 2021
1 parent 0dfe2f4 commit 7e22da0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion eng/common/pipelines/templates/steps/verify-agent-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ steps:
workingDirectory: $(System.DefaultWorkingDirectory)
filePath: ${{ parameters.ScriptDirectory }}/Verify-AgentOS.ps1
arguments: >
-AgentImage ${{ parameters.AgentImage }}
-AgentImage "${{ parameters.AgentImage }}"
14 changes: 11 additions & 3 deletions eng/common/scripts/Verify-AgentOS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 7e22da0

Please sign in to comment.