Azure / azure-sdk-tools

Tools repository leveraged by the Azure SDK team.
MIT License
113 stars 177 forks source link

Update scripts and YML to use "Agent.OS" instead of custom variables like "OSVmImage" #5494

Open mikeharder opened 1 year ago

mikeharder commented 1 year ago

I believe many of our scripts and YML use custom variables like OSVmImage to detect operating system. However, I think it might be better to use the built-in variable Agent.OS instead.

image

https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml#agent-variables-devops-services

danieljurek commented 1 year ago

We can also use $IsWindows, $IsLinux, etc. in PowerShell but I want to make sure that we get the "marketing" version of the platform, e.g. Windows Server 2022 vs. Windows_NT

We were using the OS vm image as a way to discover that information without having to query the OS and then work backwards toward a version. It might make sense to parse $PSVersionTable.OS but we'll have to see how that works in the various OS' we use. It hasn't been investigated yet.

mikeharder commented 1 year ago

@danieljurek: Are you saying we have cases where we want to know the OS version (e.g. Windows 2019 vs Windows 2022), rather than just Windows vs Linux vs Mac? In that case, I agree OSVmImage might be preferable to Agent.OS.

But I also know we have code that maps OSVmImage to one of the three operating systems, and I think that code could be replaced by Agent.OS.

danieljurek commented 1 year ago

Correct, we try to put the OS marketing version in the output: https://github.com/Azure/azure-sdk-for-cpp/blob/main/eng/scripts/Get-BinarySizes.ps1#L56