Azure devops:如何区分 Microsoft 和自托管代理

Azure devops: How to distinguish between Microsoft and Self hosted agents

要知道您是否 CI 在本地工作,您可以使用 TF_BUILD,但我看不到任何环境变量可以帮助我辨别 自托管Microsoft 托管的 代理。

如何做到这一点,而不必在我们的自托管机器中手动定义自定义环境变量?

更新:我为什么需要这个?有些东西以一种或另一种方式工作,具体取决于它是 ms 托管还是自托管。例如python 虚拟环境见 microsoft/azure-pipelines-tasks Issue 15417

使用 Agent.Name 怎么样?它是一个预定义变量,具有:

The name of the agent that is registered with the pool.
If you are using a self-hosted agent, then this name is specified by you. See agents.

假设您的命名方案允许您区分您自己的代理和 MS 托管的代理,那应该可以完成这项工作吗?