Skip to content

Commit

Permalink
Set service name correctly when using Azure Pipelines urls (#1846)
Browse files Browse the repository at this point in the history
The previous service naming logic used the instance's subdomain. When an
Azure Pipelines url was provided, "dev" was always used. Now, the instance
name will be obtained from the url's path if an Azure Pipelines url is
provided.

Resolves #1841
  • Loading branch information
JacobHenner authored and TingluoHuang committed Sep 26, 2018
1 parent 176f400 commit 584f67c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Agent.Listener/Configuration/ServiceControlManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,18 @@ public void CalculateServiceName(AgentSettings settings, string serviceNamePatte
serviceName = string.Empty;
serviceDisplayName = string.Empty;

string accountName = new Uri(settings.ServerUrl).Host.Split('.').FirstOrDefault();
Uri accountUri = new Uri(settings.ServerUrl);
string accountName = string.Empty;

if (accountUri.Host.Equals("dev.azure.com", StringComparison.OrdinalIgnoreCase))
{
accountName = accountUri.AbsolutePath.Split('/', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
}
else
{
accountName = accountUri.Host.Split('.').FirstOrDefault();
}

if (string.IsNullOrEmpty(accountName))
{
throw new InvalidOperationException(StringUtil.Loc("CannotFindHostName", settings.ServerUrl));
Expand Down

0 comments on commit 584f67c

Please sign in to comment.