Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Added the site name to the deployment status and with that to the pos…
Browse files Browse the repository at this point in the history
…t deployment web hook.

Fixes #906
  • Loading branch information
Amit Apple committed Jan 1, 2014
1 parent 89d5c4c commit 2933e47
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Kudu.Contracts/Deployment/DeployResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ public class DeployResult

[DataMember(Name = "log_url")]
public Uri LogUrl { get; set; }

[DataMember(Name = "site_name")]
public string SiteName { get; set; }
}
}
}
3 changes: 2 additions & 1 deletion Kudu.Contracts/Deployment/IDeploymentStatusFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public interface IDeploymentStatusFile
bool Complete { get; set; }
bool IsTemporary { get; set; }
bool IsReadOnly { get; set; }
string SiteName { get; }

void Save();
}
}
}
2 changes: 2 additions & 0 deletions Kudu.Core.Test/Deployment/DeploymentManagerFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public class TestDeploymentStatusFile : IDeploymentStatusFile

public bool IsReadOnly { get; set; }

public string SiteName { get; set; }

public void Save()
{
// Do nothing.
Expand Down
3 changes: 2 additions & 1 deletion Kudu.Core/Deployment/DeploymentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ private DeployResult GetResult(string id, string activeDeploymentId, bool isDepl
IsReadOnly = file.IsReadOnly,
Current = file.Id == activeDeploymentId,
ReceivedTime = file.ReceivedTime,
LastSuccessEndTime = file.LastSuccessEndTime
LastSuccessEndTime = file.LastSuccessEndTime,
SiteName = file.SiteName
};
}

Expand Down
22 changes: 19 additions & 3 deletions Kudu.Core/Deployment/DeploymentStatusFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO.Abstractions;
using System.Xml.Linq;
using Kudu.Contracts.Infrastructure;
using Kudu.Core.Deployment;
using Kudu.Core.Infrastructure;

namespace Kudu.Core.Deployment
Expand All @@ -29,6 +28,8 @@ private DeploymentStatusFile(string id, IEnvironment environment, IFileSystem fi

Id = id;

SiteName = GetSiteName(environment);

if (document != null)
{
Initialize(document);
Expand Down Expand Up @@ -136,6 +137,7 @@ private void Initialize(XDocument document)
public bool Complete { get; set; }
public bool IsTemporary { get; set; }
public bool IsReadOnly { get; set; }
public string SiteName { get; private set; }

public void Save()
{
Expand Down Expand Up @@ -194,10 +196,24 @@ private static string GetOptionalElementValue(XElement element, string localName
}
return child != null ? child.Value : null;
}

private static DateTime? ParseDateTime(string value)
{
return !String.IsNullOrEmpty(value) ? DateTime.Parse(value).ToUniversalTime() : (DateTime?)null;
}

private static string GetSiteName(IEnvironment environment)
{
// Try to get the site name from the environment (WAWS will set it)
string siteName = System.Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME");

if (String.IsNullOrEmpty(siteName))
{
// Otherwise get it from the root directory name
siteName = Path.GetFileName(environment.RootPath);
}

return siteName;
}
}
}
}

0 comments on commit 2933e47

Please sign in to comment.