private bool HasBuild(AllBuildDetails allBuildDetails) { // no details, there is no build if (allBuildDetails == null) return false; // if there is a completed build, there is a build if (allBuildDetails.LastCompletedBuild != null) return true; // if there is a build in progress, there is a build bool buildInProgress = allBuildDetails.Status.IsInProgress; return buildInProgress; }
public AllBuildDetails UpdateProject(Project project) { String url = NetUtils.ConcatUrls(project.Url, "/api/xml"); //logger.Info("Updating project from " + url); Credentials credentials = project.Server.Credentials; bool ignoreUntrustedCertificate = project.Server.IgnoreUntrustedCertificate; String xmlStr = DownloadString(credentials, url, false, ignoreUntrustedCertificate); if (logger.IsTraceEnabled) logger.Trace("XML: " + xmlStr); XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStr); bool? inQueue = XmlUtils.SelectSingleNodeBoolean(xml, "/*/inQueue"); string inQueueSince = XmlUtils.SelectSingleNodeText(xml, "/*/queueItem/inQueueSince"); string queueId = XmlUtils.SelectSingleNodeText(xml, "/*/queueItem/id"); string why = XmlUtils.SelectSingleNodeText(xml, "/*/queueItem/why"); bool? stuck = XmlUtils.SelectSingleNodeBoolean(xml, "/*/queueItem/stuck"); 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"); project.Queue.InQueue = (inQueue.HasValue && inQueue.Value == true); if (!String.IsNullOrEmpty(queueId)) { project.Queue.Id = long.Parse(queueId); } if (!String.IsNullOrEmpty(inQueueSince)) { TimeSpan ts = TimeSpan.FromSeconds(long.Parse(inQueueSince) / 1000); DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); date = date.Add(ts); project.Queue.InQueueSince = date; } if (!String.IsNullOrEmpty(why)) { project.Queue.Why = why; } 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); //logger.Info("Done updating project"); return res; }