async Task ImportVstsReleasesDataAsync(ReleaseManagement releaseManagement, string branch, ReleaseDefinitionId releaseDefinitionId) { Console.WriteLine($"Import VSTS releases from branch [{branch}] started at {DateTime.UtcNow}."); SqlConnection sqlConnection = null; try { sqlConnection = new SqlConnection(this.dbConnectionString); sqlConnection.Open(); List <IoTEdgeRelease> releaseResults = await releaseManagement.GetReleasesAsync(releaseDefinitionId, branch, 200); Console.WriteLine($"Query VSTS releases for branch [{branch}] and release definition [{releaseDefinitionId.ToString()}]: result count={releaseResults.Count} at {DateTime.UtcNow}."); int releaseCount = 0; foreach (IoTEdgeRelease release in releaseResults.Where(r => r.HasResult())) { UpsertVstsReleaseToDb(sqlConnection, release); foreach (KeyValuePair <int, string> kvp in ReleaseEnvironment.DefinitionIdToDisplayNameMapping) { IoTEdgeReleaseEnvironment releaseEnvironment = release.GetEnvironment(kvp.Key); if (releaseEnvironment.HasResult()) { UpsertVstsReleaseEnvironmentToDb(sqlConnection, release.Id, releaseEnvironment, kvp.Value); foreach (IoTEdgeReleaseDeployment deployment in releaseEnvironment.Deployments) { UpsertVstsReleaseDeploymentToDb(sqlConnection, releaseEnvironment.Id, deployment); const string testTaskPrefix = "Test:"; foreach (IoTEdgePipelineTask pipelineTask in deployment.Tasks.Where(x => IsTestTask(x, testTaskPrefix))) { UpsertVstsReleaseTaskToDb(sqlConnection, deployment.Id, pipelineTask, testTaskPrefix); } } } } releaseCount++; if (releaseCount % 10 == 0) { Console.WriteLine($"Query VSTS releases for branch [{branch}] and release definition [{releaseDefinitionId.ToString()}]: release count={releaseCount} at {DateTime.UtcNow}."); } } } catch (Exception) { throw; } finally { sqlConnection?.Close(); } }
async Task ImportVstsReleasesDataAsync(ReleaseManagement releaseManagement, string branch, ReleaseDefinitionId releaseDefinitionId) { SqlConnection sqlConnection = null; try { sqlConnection = new SqlConnection(this.dbConnectionString); sqlConnection.Open(); List <IoTEdgeRelease> releaseResults = await releaseManagement.GetReleasesAsync(releaseDefinitionId, branch, 200); Console.WriteLine($"Query VSTS for branch [{branch}] and release definition [{releaseDefinitionId.ToString()}]: result count={releaseResults.Count}"); foreach (IoTEdgeRelease release in releaseResults.Where(r => r.HasResult())) { UpsertVstsReleaseToDb(sqlConnection, release); foreach (KeyValuePair <int, string> kvp in ReleaseEnvironment.DefinitionIdToDisplayNameMapping) { IoTEdgeReleaseEnvironment releaseEnvironment = release.GetEnvironment(kvp.Key); if (releaseEnvironment.HasResult()) { UpsertVstsReleaseEnvironmentToDb(sqlConnection, release.Id, releaseEnvironment, kvp.Value); } } } } catch (Exception) { throw; } finally { sqlConnection?.Close(); } }
public static string DisplayName(this ReleaseDefinitionId releaseDefinitionId) { var definitionIdToDisplayNameMapping = new Dictionary <ReleaseDefinitionId, string> { { ReleaseDefinitionId.E2ETest, "Old E2E Test" }, }; return(definitionIdToDisplayNameMapping.ContainsKey(releaseDefinitionId) ? definitionIdToDisplayNameMapping[releaseDefinitionId] : releaseDefinitionId.ToString()); }