예제 #1
0
        public async Task InitAsync()
        {
            // Convert the rollout start time and end time to the strings the AzDO API recognizes and fetch builds
            string rolloutStartTimeUriString = RolloutStartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
            string rolloutEndTimeUriString   = RolloutEndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");

            foreach (string buildDefinitionId in RepoConfig.BuildDefinitionIds)
            {
                string azdoQuery = $"https://dev.azure.com/{RepoConfig.AzdoInstance}/" +
                                   $"{AzdoConfig.Project}/_apis/build/builds?definitions={buildDefinitionId}&branchName={Branch}" +
                                   $"&minTime={rolloutStartTimeUriString}&maxTime={rolloutEndTimeUriString}&api-version=5.1";
                Utilities.WriteDebug($"Querying AzDO API: {azdoQuery}", Log, LogLevel);
                JObject responseContent = await GetAzdoApiResponseAsync(azdoQuery);

                // No builds is a valid case (e.g. a failed rollout) and so the rest of the code can handle this
                // It still is potentially unexpected, so we're going to warn the user here
                if (responseContent.Value <int>("count") == 0)
                {
                    Utilities.WriteWarning($"No builds were found for repo '{RepoConfig.Repo}' " +
                                           $"(Build ID: '{buildDefinitionId}') during the specified dates ({RolloutStartDate} to {RolloutEndDate})", Log);
                }

                JArray builds = responseContent.Value <JArray>("value");
                foreach (JToken build in builds)
                {
                    BuildBreakdowns.Add(new ScorecardBuildBreakdown(build.ToObject <BuildSummary>()));
                }
            }
            BuildBreakdowns = BuildBreakdowns.OrderBy(x => x.BuildSummary.FinishTime).ToList();
            Utilities.WriteDebug($"Builds breakdowns created for: \n\t {string.Join(" \n\t ", BuildBreakdowns.Select(b => b?.BuildSummary?.WebLink ?? ""))}", Log, LogLevel);

            await Task.WhenAll(BuildBreakdowns.Select(b => CollectStages(b)));
        }
예제 #2
0
        public async Task InitAsync()
        {
            // Convert the rollout start time and end time to the strings the AzDO API recognizes and fetch builds
            string  rolloutStartTimeUriString = RolloutStartDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
            string  rolloutEndTimeUriString   = RolloutEndDate.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ");
            JObject responseContent           = await GetAzdoApiResponseAsync($"https://dev.azure.com/{RepoConfig.AzdoInstance}/" +
                                                                              $"{AzdoConfig.Project}/_apis/build/builds?definitions={RepoConfig.DefinitionId}&branchName={Branch}" +
                                                                              $"&minTime={rolloutStartTimeUriString}&maxTime={rolloutEndTimeUriString}&api-version=5.1");

            // No builds is a valid case (e.g. a failed rollout) and so the rest of the code can handle this
            // It still is potentially unexpected, so we're going to warn the user here
            if (responseContent.Value <int>("count") == 0)
            {
                Utilities.WriteWarning($"No builds were found for repo '{RepoConfig.Repo}' " +
                                       $"(Build ID: '{RepoConfig.DefinitionId}') during the specified dates ({RolloutStartDate} to {RolloutEndDate})", Log);
            }

            JArray builds = responseContent.Value <JArray>("value");

            foreach (JToken build in builds)
            {
                BuildBreakdowns.Add(new ScorecardBuildBreakdown(build.ToObject <BuildSummary>()));
            }
        }