/// <summary> /// Builds and returns the download URLs for all code coverage reports for the specified build /// </summary> public IEnumerable <string> GetCodeCoverageReportUrls(string tfsUri, string buildUri, ILogger logger) { if (string.IsNullOrWhiteSpace(tfsUri)) { throw new ArgumentNullException("tfsUri"); } if (string.IsNullOrWhiteSpace(buildUri)) { throw new ArgumentNullException("buildUri"); } if (logger == null) { throw new ArgumentNullException("logger"); } List <string> urls = new List <string>(); logger.LogDebug(Resources.URL_DIAG_ConnectingToTfs); using (TfsTeamProjectCollection collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tfsUri))) { IBuildServer buildServer = collection.GetService <IBuildServer>(); logger.LogDebug(Resources.URL_DIAG_FetchingBuildInfo); IBuildDetail build = buildServer.GetMinimalBuildDetails(new Uri(buildUri)); string projectName = build.TeamProject; logger.LogDebug(Resources.URL_DIAG_FetchingCoverageReportInfo); ITestManagementService tcm = collection.GetService <ITestManagementService>(); ITestManagementTeamProject testProject = tcm.GetTeamProject(projectName); // TODO: investigate further. It looks as if we might be requesting the coverage reports // before the service is able to provide them. // For the time being, we're retrying with a time out. IBuildCoverage[] coverages = null; Utilities.Retry(TimeoutInMs, RetryPeriodInMs, logger, () => { return(TryGetCoverageInfo(testProject, buildUri, out coverages)); }); foreach (IBuildCoverage coverage in coverages) { logger.LogDebug(Resources.URL_DIAG_CoverageReportInfo, coverage.Configuration.Id, coverage.Configuration.BuildPlatform, coverage.Configuration.BuildPlatform); string coverageFileUrl = CoverageReportUrlProvider.GetCoverageUri(build, coverage); Debug.WriteLine(coverageFileUrl); urls.Add(coverageFileUrl); } } logger.LogDebug(Resources.URL_DIAG_Finished); return(urls); }