azure-sdk-for-cpp/eng/common/scripts/Verify-AgentOS.ps1
Azure SDK Bot a7ce0d5ae3
Sync eng/common directory with azure-sdk-tools for PR 7810 (#5412)
* Run publish on failed or succeeded

* Expand agent os string detection

* Check agent job status env var for artifact name detection

* Add sbomEnabled flag to publish template

* Fix image and artifact name conditional

---------

Co-authored-by: Ben Broderick Phillips <bebroder@microsoft.com>
2024-03-05 17:47:38 -05:00

22 lines
676 B
PowerShell

param (
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string] $AgentImage
)
function Throw-InvalidOperatingSystem {
throw "Invalid operating system detected. Operating system was: $([System.Runtime.InteropServices.RuntimeInformation]::OSDescription), expected image was: $AgentImage"
}
if ($IsWindows -and $AgentImage -match "windows|win|MMS\d{4}") {
$osName = "Windows"
} elseif ($IsLinux -and $AgentImage -match "ubuntu|linux") {
$osName = "Linux"
} elseif ($IsMacOs -and $AgentImage -match "macos|macOS") {
$osName = "macOS"
} else {
Throw-InvalidOperatingSystem
}
Write-Host "##vso[task.setvariable variable=OSName]$osName"