Is it possible to determine within a single YAML Pipeline whether the agent is running self-hosted or in a cloud build? If so, how would one go about determining that?
I need my pipeline to work in both locations but certain steps must only occur if I'm building on one or the other.
I can't find directly solution, but it could be done using conditions and agent variables.
For example I have Hosted Agent
in my agents pool:
And in YAML I can use this name to condition running step depents on it:
steps:
- script: dotnet build --configuration $(buildConfiguration)
condition: eq(variables['Agent.Name'],'Hosted Agent')
displayName: 'dotnet build $(buildConfiguration)'