cake
cake copied to clipboard
VSTS IsHostedAgent detection is flawed
When running CakeBuild in VSTS and rely on Context.TFBuild().IsRunningOnVSTS
. However we have 2 hosted build agents and second build agent is called "Hosted Agent 2". And build is always failing on the second agent.
Here code insists that agent name is exactly "Hosted Agent".
Also We are setting up private build agent and this code does not agree with private build agents. It is still VSTS build, only not run in hosted agent.
I propose to change the check for the agent name to .StartsWith("Hosted Agent")
and remove check for IsHostedAgent
from IsRunningOnVSTS
option.
@agc93 what do you think? (as far as I remember you have done work on this)
I can do PR for this.
Looking on my VSTS, my other hosted agent is called "Hosted VS2017 2". So we can't rely on this value to be anything consistent.
Related to #1580.
Yep, I'll have a look at this (a few different parts of the logic need improvements)
Just ran into this issue - only need to know if its building on VSTS so now I'm doing
var isVSTS = buildSystem.TFBuild.IsRunningOnVSTS || buildSystem.TFBuild.IsRunningOnTFS;
instead of just IsRunningOnVSTS
We've just stumbled across this issue too since we've added a couple more hosted agents to our team. As a workaround we're just checking that we've got a agent name:
var isRunningOnVSTS = !string.IsNullOrEmpty(EnvironmentVariable("AGENT_NAME"));
@agc93 / @pascalberger Has this been resolved by 8d3483b
?