Пример #1
0
        private void AddBuildsErrors(IBuildDetail tfsBuild, Build build)
        {
            var associatedBuildErrors = InformationNodeConverters.GetBuildErrors(tfsBuild);

            build.Error = new Error {
                Total = associatedBuildErrors.Count()
            };
        }
Пример #2
0
        private void ValidateBuildStatus()
        {
            this.LogDebug("Validating build completed successfully...");
            var collection = this.GetTeamProjectCollection();

            var buildService    = collection.GetService <IBuildServer>();
            var buildDefinition = buildService.GetBuildDefinition(this.TeamProject, this.BuildDefinition);

            var spec = buildService.CreateBuildDetailSpec(this.TeamProject, this.BuildDefinition);

            spec.MaxBuildsPerDefinition = 1;
            spec.QueryOrder             = BuildQueryOrder.FinishTimeDescending;

            var result = buildService.QueryBuilds(spec);
            var build  = result.Builds.FirstOrDefault();

            if (build == null)
            {
                throw new InvalidOperationException($"Build {this.BuildNumber} for team project {this.TeamProject} definition {this.BuildDefinition} did not return any builds.");
            }

            if (build.Status != BuildStatus.Succeeded)
            {
                this.LogError(
                    $"There was a build error during the TFS Build {this.BuildNumber} for team project {this.TeamProject} " +
                    "and the \"Fail if the TFS build does not succeed\" option was selected for this build."
                    );

                var buildErrors = InformationNodeConverters.GetBuildErrors(build);

                this.LogError("Build errors were reported:");
                foreach (var error in buildErrors)
                {
                    this.LogError($"{error.ServerPath}; Line {error.LineNumber}: ErrMsg {error.Message}");
                }
            }
        }