public Models.Build GetLatestFailedBuild() { try { var projects = _client.Projects.All(); var failedBuilds = new List <Build>(); foreach (var project in projects) { var p = _client.Projects.ById(project.Id); if (p.BuildTypes != null) { foreach (var buildId in p.BuildTypes.BuildType.Select(x => x.Id)) { failedBuilds.AddRange(_client.Builds.ByBuildLocator(new FluidBuildLocator() .WithBuildType(FluidBuildTypeLocator.WithId(buildId)) .WithBranch(new FluidBranchLocator().WithDefault(BranchLocatorFlag.Any)) .WithSinceDate(DateTime.Now.AddDays(-14)) .WithStatus(BuildStatus.FAILURE))); } } } if (failedBuilds.Any()) { var buildList = new List <Models.Build>(); foreach (var failedBuild in failedBuilds) { var build = PopulateBuild(failedBuild); buildList.Add(build); } var lastFailedBuild = buildList.OrderByDescending(x => x.FinishDate).First(); return(lastFailedBuild); } } catch (Exception ex) { _log.Error("Get latest failed build from TC failed.", ex); } return(null); }
public void ReturnsWithId() { var locator = FluidBuildTypeLocator.WithId("bt9999"); Assert.AreEqual("id:bt9999", locator.ToString()); }
public List <Models.Build> GetAllBuilds() { try { var projects = _client.Projects.All(); var builds = new List <Models.Build>(); foreach (var project in projects) { var p = _client.Projects.ById(project.Id); if (p.BuildTypes != null) { foreach (var buildId in p.BuildTypes.BuildType.Select(x => x.Id)) { var tcBuilds = _client.Builds.ByBuildLocator(new FluidBuildLocator() .WithBuildType(FluidBuildTypeLocator.WithId(buildId)) .WithBranch(new FluidBranchLocator().WithDefault(BranchLocatorFlag.Any))); if (tcBuilds != null && tcBuilds.Any()) { var tcBuild = tcBuilds.First(); if (tcBuild != null) { var build = PopulateBuild(tcBuild); builds.Add(build); } } } } } return(builds.OrderByDescending(x => x.FinishDate).ToList()); } catch (Exception ex) { _log.Error("Get all builds from TC failed.", ex); } return(new List <Models.Build>()); }
public void ReturnsWithEmptyId() { var locator = FluidBuildTypeLocator.WithId(string.Empty); Assert.AreEqual(string.Empty, locator.ToString()); }