Skip to content

Commit

Permalink
#1. Added Last build column. Includes custom display name of the build.
Browse files Browse the repository at this point in the history
  • Loading branch information
zionyx committed Oct 27, 2014
1 parent 1248aa2 commit c4ee95d
Show file tree
Hide file tree
Showing 9 changed files with 234 additions and 127 deletions.
10 changes: 10 additions & 0 deletions HudsonTrayTracker/BusinessComponents/HudsonService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ public AllBuildDetails UpdateProject(Project project)
xml.LoadXml(xmlStr);

string status = xml.SelectSingleNode("/*/color").InnerText;
string lastBuildUrl = XmlUtils.SelectSingleNodeText(xml, "/*/lastBuild/url");
string lastCompletedBuildUrl = XmlUtils.SelectSingleNodeText(xml, "/*/lastCompletedBuild/url");
string lastSuccessfulBuildUrl = XmlUtils.SelectSingleNodeText(xml, "/*/lastSuccessfulBuild/url");
string lastFailedBuildUrl = XmlUtils.SelectSingleNodeText(xml, "/*/lastFailedBuild/url");
bool? stuck = XmlUtils.SelectSingleNodeBoolean(xml, "/*/queueItem/stuck");

AllBuildDetails res = new AllBuildDetails();
res.Status = GetStatus(status, stuck);
res.LastBuild = GetBuildDetails(credentials, lastBuildUrl, ignoreUntrustedCertificate);
res.LastCompletedBuild = GetBuildDetails(credentials, lastCompletedBuildUrl, ignoreUntrustedCertificate);
res.LastSuccessfulBuild = GetBuildDetails(credentials, lastSuccessfulBuildUrl, ignoreUntrustedCertificate);
res.LastFailedBuild = GetBuildDetails(credentials, lastFailedBuildUrl, ignoreUntrustedCertificate);
Expand Down Expand Up @@ -148,13 +150,18 @@ private BuildDetails GetBuildDetails(Credentials credentials, string buildUrl, b
XmlDocument xml = new XmlDocument();
xml.LoadXml(xmlStr);

string cause = xml.SelectSingleNode("/*/action/cause[last()]/shortDescription").InnerText;
string number = xml.SelectSingleNode("/*/number").InnerText;
string fullDisplayName = xml.SelectSingleNode("/*/fullDisplayName").InnerText;
string timestamp = xml.SelectSingleNode("/*/timestamp").InnerText;
string estimatedDuration = xml.SelectSingleNode("/*/estimatedDuration").InnerText;
XmlNodeList userNodes = xml.SelectNodes("/*/culprit/fullName");

TimeSpan ts = TimeSpan.FromSeconds(long.Parse(timestamp) / 1000);
DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
date = date.Add(ts);
TimeSpan durationts = TimeSpan.FromSeconds(long.Parse(estimatedDuration) / 1000);
DateTime duration = date.Add(durationts);

ISet<string> users = new HashedSet<string>();
foreach (XmlNode userNode in userNodes)
Expand All @@ -164,8 +171,11 @@ private BuildDetails GetBuildDetails(Credentials credentials, string buildUrl, b
}

BuildDetails res = new BuildDetails();
res.Cause = cause;
res.Number = int.Parse(number);
res.DisplayName = fullDisplayName;
res.Time = date;
res.EstimatedDuration = duration;
res.Users = users;

ClaimService.FillInBuildDetails(res, xml);
Expand Down
2 changes: 1 addition & 1 deletion HudsonTrayTracker/Entities/AllBuildDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Hudson.TrayTracker.Entities
public class AllBuildDetails
{
public BuildStatus Status { get; set; }
//public BuildDetails LastBuild { get; set; }
public BuildDetails LastBuild { get; set; }
public BuildDetails LastCompletedBuild { get; set; }
public BuildDetails LastSuccessfulBuild { get; set; }
public BuildDetails LastFailedBuild { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions HudsonTrayTracker/Entities/BuildDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ namespace Hudson.TrayTracker.Entities
{
public class BuildDetails
{
public string Cause { get; set; }
public int Number { get; set; }
public string Url { get; set; }
public string DisplayName { get; set; }
public DateTime Time { get; set; }
public DateTime EstimatedDuration { get; set; }
public ISet<string> Users { get; set; }
public ClaimDetails ClaimDetails { get; set; }
}
Expand Down
13 changes: 13 additions & 0 deletions HudsonTrayTracker/Entities/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ public BuildStatus Status
return details.Status;
}
}

public BuildStatusEnum StatusValue
{
get { return Status.Value; }
}

public BuildDetails LastBuild
{
get
{
// get a copy of the reference to avoid a race condition
AllBuildDetails details = this.AllBuildDetails;
if (details == null)
return null;
return details.LastBuild;
}
}

public BuildDetails LastSuccessfulBuild
{
get
Expand Down
27 changes: 20 additions & 7 deletions HudsonTrayTracker/HudsonTrayTrackerResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions HudsonTrayTracker/HudsonTrayTrackerResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ Do you want to download it now (the application will be closed)?</value>
<data name="BuildDetails_Format_NumberDate" xml:space="preserve">
<value>{0} ({1})</value>
</data>
<data name="BuildDetails_Format_DisplayName_NumberDate" xml:space="preserve">
<value>{0} - {1} ({2})</value>
</data>
<data name="BuildDetails_Format_NumberDateUsers" xml:space="preserve">
<value>{0} ({1}, {2})</value>
</data>
Expand All @@ -152,10 +155,10 @@ Do you want to download it now (the application will be closed)?</value>
<value>Build failed</value>
</data>
<data name="BuildStatus_Failed_BuildInProgress" xml:space="preserve">
<value>Build failed. Build in progress.</value>
<value>Last build failed. Build in progress.</value>
</data>
<data name="BuildStatus_Failed_Stuck" xml:space="preserve">
<value>Build failed. Build is stuck.</value>
<value>Last build failed. Build is stuck.</value>
</data>
<data name="BuildStatus_Indeterminate" xml:space="preserve">
<value>Indeterminate: no build done.</value>
Expand Down
34 changes: 31 additions & 3 deletions HudsonTrayTracker/UI/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions HudsonTrayTracker/UI/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@ public string Url
{
get { return Uri.UnescapeDataString(Project.Url); }
}

public string buildDetailsStr
{
get { return FormatBuildDetailsAndSummary(); }
}
public string lastBuildStr
{
get { return FormatBuildDetailsWithDisplayName(LastBuild); }
}

public BuildDetails LastBuild
{
get { return Project.LastBuild; }
}

public BuildDetails LastSuccessBuild
{
get { return Project.LastSuccessfulBuild; }
Expand Down Expand Up @@ -349,6 +364,31 @@ public string ClaimReason
}
}

private string FormatBuildDetailsAndSummary()
{
return string.Empty;
}

private string FormatBuildDetailsWithDisplayName(BuildDetails details)
{
if (details == null)
return "-";
string shortDisplayName = details.DisplayName.Replace(Project.Name, string.Empty).Trim();

string res = string.Empty;
if (shortDisplayName.Equals(string.Concat("#", details.Number.ToString())))
{
res = string.Format(HudsonTrayTrackerResources.BuildDetails_Format_NumberDate,
details.Number.ToString(), details.Time.ToLocalTime());
}
else
{
res = string.Format(HudsonTrayTrackerResources.BuildDetails_Format_DisplayName_NumberDate,
shortDisplayName, details.Number.ToString(), details.Time.ToLocalTime());
}
return res;
}

private string FormatBuildDetails(BuildDetails details)
{
if (details == null)
Expand Down
Loading

0 comments on commit c4ee95d

Please sign in to comment.