Skip to content

Commit

Permalink
build v.2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Steiger committed Dec 23, 2015
1 parent b1fc914 commit 76af716
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class Build
public DateTime FinishTime { get; set; }
public DateTime StartTime { get; set; }
public string Status { get; set; }
public string Result { get; set; }
public RequestedFor RequestedFor { get; set; }
public Request[] Requests { get; set; }
public string Uri { get; set; }
public Definition Definition { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ private IEnumerable<BuildInfoDto> GetBuildsForPollingSince(string teamProjectNam
{
List<BuildInfoDto> dtos = new List<BuildInfoDto>();
try
{
{
var polledBuilds = GetPolledBuilds(teamProjectName, finishTime);
Parallel.ForEach(polledBuilds, new ParallelOptions { MaxDegreeOfParallelism = DegreeOfParallelism }, build =>
{
var buildInfoDto = new BuildInfoDto
{
TeamProject = teamProjectName,
Status = build.Status,
Status = build.Result,
Builddefinition = build.Definition.Name,
StartBuildDateTime = build.StartTime,
FinishBuildDateTime = build.FinishTime,
RequestedByName = build.Requests.First().RequestedFor.DisplayName,
RequestedByPictureUrl = build.Requests.First().RequestedFor.ImageUrl + "&size=2",
RequestedByName = build.RequestedFor.DisplayName,
RequestedByPictureUrl = build.RequestedFor.ImageUrl,
TotalNumberOfTests = 0,
PassedNumberOfTests = 0,
BuildReportUrl = _helperClass.ConvertReportUrl(teamProjectName, build.Uri, true),
Expand All @@ -82,13 +82,15 @@ private IEnumerable<BuildInfoDto> GetBuildsForPollingSince(string teamProjectNam
{
buildInfoDto.BuildReportUrl = _helperClass.ConvertReportUrl(teamProjectName, build.Uri, false);
var lastBuildTime = GetLastBuildTime(teamProjectName, build);
buildInfoDto.Status = StatusEnum.Statuses.inProgress.ToString();
if (lastBuildTime != null)
{
buildInfoDto.LastBuildTime = lastBuildTime.FinishTime - lastBuildTime.StartTime;
}
}
if (
build.Status.Equals(Enum.GetName(typeof(StatusEnum.Statuses),
build.Result != null &&
build.Result.Equals(Enum.GetName(typeof(StatusEnum.Statuses),
StatusEnum.Statuses.partiallySucceeded)))
{
var results = GetTestResults(teamProjectName, build.Uri);
Expand Down Expand Up @@ -225,19 +227,19 @@ private BuildInfoDto GetLatestBuild(string teamProjectName, string bdId, string
var latestBuild =
_helperClass
.RetrieveTask<Build>(
(String.Format(_configurationRestService.RetrieveLastBuildAsyncUrl, teamProjectName, bdUri)))
(String.Format(_configurationRestService.RetrieveLastBuildAsyncUrl, teamProjectName, bdId)))
.Result
.FirstOrDefault();
if (latestBuild == null) return null;
buildInfoDto = new BuildInfoDto
{
TeamProject = teamProjectName,
Status = latestBuild.Status,
Status = latestBuild.Result,
Builddefinition = bdName,
StartBuildDateTime = latestBuild.StartTime,
FinishBuildDateTime = latestBuild.FinishTime,
RequestedByName = latestBuild.Requests.First().RequestedFor.DisplayName,
RequestedByPictureUrl = latestBuild.Requests.First().RequestedFor.ImageUrl + "&size=2",
RequestedByName = latestBuild.RequestedFor.DisplayName,
RequestedByPictureUrl = latestBuild.RequestedFor.ImageUrl,
TotalNumberOfTests = 0,
PassedNumberOfTests = 0,
BuildReportUrl = _helperClass.ConvertReportUrl(teamProjectName, latestBuild.Uri, true),
Expand All @@ -246,6 +248,7 @@ private BuildInfoDto GetLatestBuild(string teamProjectName, string bdId, string
if (latestBuild.Status.Equals(Enum.GetName(typeof(StatusEnum.Statuses), StatusEnum.Statuses.inProgress)))
{
buildInfoDto.BuildReportUrl = _helperClass.ConvertReportUrl(teamProjectName, latestBuild.Uri, false);
buildInfoDto.Status = StatusEnum.Statuses.inProgress.ToString();
var secondLastBuildList =
_helperClass.RetrieveTask<Build>(
(String.Format(_configurationRestService.RetrieveLastSuccessfulBuildUrl, teamProjectName, bdUri))).Result;
Expand All @@ -257,7 +260,8 @@ private BuildInfoDto GetLatestBuild(string teamProjectName, string bdId, string
}

}
if (latestBuild.Status.Equals(Enum.GetName(typeof(StatusEnum.Statuses), StatusEnum.Statuses.partiallySucceeded)))
if (latestBuild.Result != null &&
latestBuild.Result.Equals(Enum.GetName(typeof(StatusEnum.Statuses), StatusEnum.Statuses.partiallySucceeded)))
{
var results = GetTestResults(teamProjectName, latestBuild.Uri);
if (results != null)
Expand Down
10 changes: 5 additions & 5 deletions OrbitOne.BuildScreen/OrbitOne.BuildScreen/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<ConfigurationRestService RetrieveProjectsAsyncUrl="DefaultCollection/_apis/projects?api-version=2.0"
RetrieveBuildsOnFinishtime="Defaultcollection/{0}/_apis/build/builds?api-version=2.0&amp;minfinishtime={1}"
RetrieveBuildsInProgress="Defaultcollection/{0}/_apis/build/builds?status=InProgress&amp;api-version=2.0"
RetrieveLastBuildAsyncUrl="DefaultCollection/{0}/_apis/build/builds?api-version=2.0&amp;definition={1}&amp;$top=1"
RetrieveLastSuccessfulBuildUrl="DefaultCollection/{0}/_apis/build/builds?api-version=2.0&amp;definition={1}&amp;status=succeeded&amp;$top=1"
RetriveLastPartiallyOrFailedUrl="/DefaultCollection/{0}/_apis/build/builds?api-version=2.0&amp;definition={1}&amp;status=failed,partiallysucceeded&amp;$top=1"
RetrieveBuildsOnFinishtime="Defaultcollection/{0}/_apis/build/builds?api-version=2.0&amp;minFinishTime={1}"
RetrieveBuildsInProgress="Defaultcollection/{0}/_apis/build/builds?statusFilter=inProgress&amp;api-version=2.0"
RetrieveLastBuildAsyncUrl="DefaultCollection/{0}/_apis/build/builds?api-version=2.0&amp;definitions={1}&amp;$top=1"
RetrieveLastSuccessfulBuildUrl="DefaultCollection/{0}/_apis/build/builds?api-version=2.0&amp;definitions={1}&amp;resultFilter=succeeded&amp;$top=1"
RetriveLastPartiallyOrFailedUrl="/DefaultCollection/{0}/_apis/build/builds?api-version=2.0&amp;definitions={1}&amp;resultFilter=failed,partiallySucceeded&amp;$top=1"
RetrieveBuildDefinitionsUrl="DefaultCollection/{0}/_apis/build/definitions?api-version=2.0"
RetrieveRunsAsyncUrl="DefaultCollection/{0}/_apis/test/runs?api-version=2.0&amp;builduri={1}"
RetrieveTestsAsyncUrl="DefaultCollection/{0}/_apis/test/Runs/{1}/results?api-version=2.0"
Expand Down

0 comments on commit 76af716

Please sign in to comment.