public async Task PublishCoverageSummary(CoverageSummary coverageSummary, CancellationToken cancellationToken) { var coverageData = coverageSummary.CodeCoverageData; var coverageStats = coverageData?.CoverageStats; if (coverageData != null && coverageStats != null && coverageStats.Count() > 0) { // log coverage stats TraceLogger.Info(Resources.PublishingCodeCoverageSummary); foreach (var coverage in coverageStats) { TraceLogger.Info(string.Format(Resources.CoveredStats, coverage.Label, coverage.Covered, coverage.Total)); } try { var uploadToTcm = _featureFlagHelper.GetFeatureFlagState(Constants.FeatureFlags.EnablePublishToTcmServiceDirectlyFromTaskFF, false); _executionContext.TelemetryDataCollector.AddOrUpdate("UploadToTcm", uploadToTcm.ToString()); // Upload to tcm/tfs based on feature flag if (uploadToTcm) { TestResultsHttpClient tcmClient = _clientFactory.GetClient <TestResultsHttpClient>(); using (new SimpleTimer("AzurePipelinesPublisher", "UploadSummary", _executionContext.TelemetryDataCollector)) { await tcmClient.UpdateCodeCoverageSummaryAsync(coverageData, _executionContext.ProjectId, _executionContext.BuildId, cancellationToken : cancellationToken); } } else { TestManagementHttpClient tfsClient = _clientFactory.GetClient <TestManagementHttpClient>(); using (new SimpleTimer("AzurePipelinesPublisher", "UploadSummary", _executionContext.TelemetryDataCollector)) { await tfsClient.UpdateCodeCoverageSummaryAsync(coverageData, _executionContext.ProjectId, _executionContext.BuildId, cancellationToken : cancellationToken); } } } catch (Exception ex) { TraceLogger.Error(string.Format(Resources.FailedtoUploadCoverageSummary, ex.ToString())); } } }
public async Task PublishCoverageSummaryAsync(IAsyncCommandContext context, VssConnection connection, string project, int buildId, IEnumerable <CodeCoverageStatistics> coverageData, CancellationToken cancellationToken) { // <todo: Bug 402783> We are currently passing BuildFlavor and BuildPlatform = "" There value are required be passed to command CodeCoverageData data = new CodeCoverageData() { BuildFlavor = "", BuildPlatform = "", CoverageStats = coverageData.ToList() }; FeatureAvailabilityHttpClient featureAvailabilityHttpClient = connection.GetClient <FeatureAvailabilityHttpClient>(); if (FeatureFlagUtility.GetFeatureFlagState(featureAvailabilityHttpClient, CodeCoverageConstants.EnablePublishToTcmServiceDirectlyFromTaskFF, context)) { TestResultsHttpClient tcmClient = connection.GetClient <TestResultsHttpClient>(); await tcmClient.UpdateCodeCoverageSummaryAsync(data, project, buildId, cancellationToken : cancellationToken); } else { TestManagementHttpClient tfsClient = connection.GetClient <TestManagementHttpClient>(); await tfsClient.UpdateCodeCoverageSummaryAsync(data, project, buildId, cancellationToken : cancellationToken); } }
public async Task <CodeCoverageSummary> UpdateCodeCoverageSummaryAsync(VssConnection connection, string project, int buildId) { TestResultsHttpClient tcmClient = connection.GetClient <TestResultsHttpClient>(); return(await tcmClient.UpdateCodeCoverageSummaryAsync(project, buildId)); }