Skip to content

Commit

Permalink
Merge branch 'gitfool-gh2432' into develop
Browse files Browse the repository at this point in the history
* gitfool-gh2432:
  Fix environment variable used by TFBuildAgentInfo.MachineName
  Fix TFBuildProvider.IsHostedAgent for Azure Pipelines
  • Loading branch information
devlead committed Jan 7, 2019
2 parents 62b3bda + fa13221 commit 37e79be
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Cake.Common.Tests/Fixtures/Build/TFBuildInfoFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public TFBuildInfoFixture()
Environment.GetEnvironmentVariable("AGENT_WORKFOLDER").Returns(@"c:\agent\_work");
Environment.GetEnvironmentVariable("AGENT_ID").Returns("71");
Environment.GetEnvironmentVariable("AGENT_NAME").Returns("Agent-1");
Environment.GetEnvironmentVariable("AGENT_MACHINE_NAME").Returns("BuildServer");
Environment.GetEnvironmentVariable("AGENT_MACHINENAME").Returns("BuildServer");

// VSTS BuildInfo
Environment.GetEnvironmentVariable("BUILD_BUILDID").Returns("100234");
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Common/Build/TFBuild/Data/TFBuildAgentInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public TFBuildAgentInfo(ICakeEnvironment environment)
/// <value>
/// The name of the machine on which the agent is installed.
/// </value>
public string MachineName => GetEnvironmentString("AGENT_MACHINE_NAME");
public string MachineName => GetEnvironmentString("AGENT_MACHINENAME");

/// <summary>
/// Gets a value indicating whether the current agent is a hosted agent.
Expand Down
5 changes: 2 additions & 3 deletions src/Cake.Common/Build/TFBuild/TFBuildProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public bool IsRunningOnTFS
/// <c>true</c> if the current build is running on a hosted agent; otherwise, <c>false</c>.
/// </value>
private bool IsHostedAgent
=>
!string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("AGENT_NAME")) &&
_environment.GetEnvironmentVariable("AGENT_NAME") == "Hosted Agent";
=> !string.IsNullOrWhiteSpace(_environment.GetEnvironmentVariable("AGENT_NAME")) &&
_environment.GetEnvironmentVariable("AGENT_NAME").StartsWith("Hosted");
}
}

0 comments on commit 37e79be

Please sign in to comment.