Esempio n. 1
0
        private async Task <bool> HasInProgressBuildAsync(IBuildHttpClient client, int pipelineId, Guid projectId)
        {
            IPagedList <Build> builds = await client.GetBuildsAsync(
                projectId, definitions : new int[] { pipelineId }, statusFilter : BuildStatus.InProgress);

            return(builds.Any());
        }
Esempio n. 2
0
        private static async Task <IEnumerable <string> > GetInProgressBuildsAsync(IBuildHttpClient client, int pipelineId, Guid projectId)
        {
            IPagedList <WebApi.Build> builds = await client.GetBuildsAsync(
                projectId, definitions : new int[] { pipelineId }, statusFilter : WebApi.BuildStatus.InProgress);

            return(builds.Select(build => build.GetWebLink()));
        }
Esempio n. 3
0
        private static async Task <(bool ShouldSkipBuild, IEnumerable <string> RecentFailedBuilds)> ShouldDisallowBuildDueToRecentFailuresAsync(
            IBuildHttpClient client, int pipelineId, Guid projectId)
        {
            List <WebApi.Build> autoBuilderBuilds = (await client.GetBuildsAsync(projectId, definitions: new int[] { pipelineId }))
                                                    .Where(build => build.Tags.Contains(AzdoTags.AutoBuilder))
                                                    .OrderByDescending(build => build.QueueTime)
                                                    .Take(BuildFailureLimit)
                                                    .ToList();

            if (autoBuilderBuilds.Count == BuildFailureLimit &&
                autoBuilderBuilds.All(build => build.Status == WebApi.BuildStatus.Completed && build.Result == WebApi.BuildResult.Failed))
            {
                return(true, autoBuilderBuilds.Select(build => build.GetWebLink()));
            }

            return(false, Enumerable.Empty <string>());
        }