diff --git a/BuildConfigGen/Program.cs b/BuildConfigGen/Program.cs index 337c27f27832..1bd9a697a739 100644 --- a/BuildConfigGen/Program.cs +++ b/BuildConfigGen/Program.cs @@ -313,6 +313,10 @@ private static void MainUpdateTask( private static int GetCurrentSprint() { + // Scheduled time for Cortesy Push + var cortesyPushScheduleDay = DayOfWeek.Tuesday; + var cortesyPushUtcTime = new TimeOnly(8, 30); //UTC time + string url = "https://whatsprintis.it"; var httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Add("Accept", "application/json"); @@ -320,6 +324,25 @@ private static int GetCurrentSprint() string json = httpClient.GetStringAsync(url).Result; JsonDocument currentSprintData = JsonDocument.Parse(json); int currentSprint = currentSprintData.RootElement.GetProperty("sprint").GetInt32(); + int week = currentSprintData.RootElement.GetProperty("week").GetInt32(); + + if (week == 3) // if it is the end of the current sprint + { + var nowUtc = DateTime.UtcNow; + + // Increase sprint number if scheduled pipeline was already triggered + if (nowUtc.DayOfWeek > cortesyPushScheduleDay) + { + currentSprint++; + } + else if (nowUtc.DayOfWeek == cortesyPushScheduleDay) + { + if (TimeOnly.FromDateTime(nowUtc) >= cortesyPushUtcTime) + { + currentSprint++; + } + } + } return currentSprint; }