/// <summary> /// Gets the builds for the project with the specified project identifier. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns> /// A task. /// </returns> public override async Task <IEnumerable <IBuild> > GetBuildsAsync(string projectId, CancellationToken cancellationToken) { Ensure.That(projectId).IsNotNullOrWhiteSpace(); var id = Guid.Parse(projectId); var organizations = await _apiClient.GetOrganizationsAsync(cancellationToken).ConfigureAwait(false); foreach (var organization in organizations) { var page = 1; Api.Models.Projects pageable; do { pageable = await _apiClient.GetProjectsAsync(organization.Id, 50, page, cancellationToken).ConfigureAwait(false); var project = pageable.Items.FirstOrDefault(p => p.Id == id); if (project != null) { var builds = await _apiClient.GetBuildsAsync(organization.Id, project.Id, Settings.BuildsPerProject, 1, cancellationToken).ConfigureAwait(false); return(builds.Items.Select(build => new Build(build)).ToArray()); } page++; }while (!IsLastPage(pageable)); } return(new IBuild[] { }); }
/// <summary> /// Gets the builds for the project with the specified project identifier. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns> /// A task. /// </returns> public override async Task <IEnumerable <IBuild> > GetBuildsAsync(string projectId, CancellationToken cancellationToken) { Ensure.That(projectId).IsNotNullOrWhiteSpace(); var builds = await _apiClient.GetBuildsAsync(projectId, Settings.BuildsPerProject, cancellationToken).ConfigureAwait(false); return(builds.Build.Select(build => new Build(build)).ToArray()); }
/// <summary> /// Gets the builds for the project with the specified project identifier. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns> /// A task. /// </returns> public override async Task <IEnumerable <IBuild> > GetBuildsAsync(string projectId, CancellationToken cancellationToken) { Ensure.That(projectId).IsNotNullOrWhiteSpace(); var builds = new List <IBuild>(); foreach (var build in (await _apiClient.GetBuildsAsync(projectId, 0, Settings.BuildsPerProject, cancellationToken).ConfigureAwait(false)).Value) { var changes = await _apiClient.GetChangesAsync(projectId, build.Id, cancellationToken).ConfigureAwait(false); builds.Add(new Build(build, changes.Value)); } return(builds.ToArray()); }
/// <summary> /// Gets the builds for the project with the specified project identifier. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns> /// A task. /// </returns> public override async Task <IEnumerable <IBuild> > GetBuildsAsync(string projectId, CancellationToken cancellationToken) { Ensure.That(projectId).IsNotNullOrWhiteSpace(); var projects = await _apiClient.GetProjectsAsync(cancellationToken).ConfigureAwait(false); var project = projects.FirstOrDefault(p => p.Name == projectId); if (project == null) { return(new IBuild[] { }); } var builds = await _apiClient.GetBuildsAsync(project.VcsType, project.Username, project.Name, 0, Settings.BuildsPerProject, cancellationToken).ConfigureAwait(false); return(builds.Select(build => new Build(build)).ToArray()); }