Cesc
Cesc

Reputation: 1190

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

To know if you are on CI of working locally you can use TF_BUILD, but I could not see any environment variable that helps me discern between a self-hosted and a microsoft-hosted agent.

How can you do that, without having to manually define a custom environemnt variable in our self-hosted machines?

Update: why do I need this? There are things that work in one way or another depending if it is ms-hosted or self-hosted. e.g. python virtual environements see microsoft/azure-pipelines-tasks Issue 15417.

Upvotes: 0

Views: 498

Answers (1)

Vince Bowdren
Vince Bowdren

Reputation: 9208

How about using Agent.Name? It is a predefined variable, which has:

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.

Assuming your naming scheme allows you to tell the difference between your own agents and MS hosted agents, that should do the job?

Upvotes: 1

Related Questions