void GetFailureEmails(ElectricCommander EC, BuildNode NodeToDo, NodeHistory History, string CLString, string StoreName, bool OnlyLateUpdates = false) { string FailCauserEMails = ""; string EMailNote = ""; bool SendSuccessForGreenAfterRed = false; int NumPeople = 0; if (History != null) { if (History.LastSucceeded > 0 && History.LastSucceeded < P4Env.Changelist) { int LastNonDuplicateFail = P4Env.Changelist; try { if (OnlyLateUpdates) { LastNonDuplicateFail = FindLastNonDuplicateFail(NodeToDo, History, CLString, StoreName); if (LastNonDuplicateFail < P4Env.Changelist) { Log("*** Red-after-red spam reduction, changed CL {0} to CL {1} because the errors didn't change.", P4Env.Changelist, LastNonDuplicateFail); } } } catch (Exception Ex) { LastNonDuplicateFail = P4Env.Changelist; Log(System.Diagnostics.TraceEventType.Warning, "Failed to FindLastNonDuplicateFail."); Log(System.Diagnostics.TraceEventType.Warning, LogUtils.FormatException(Ex)); } if(LastNonDuplicateFail > History.LastSucceeded) { List<P4Connection.ChangeRecord> ChangeRecords = GetSourceChangeRecords(History.LastSucceeded + 1, LastNonDuplicateFail); foreach (P4Connection.ChangeRecord Record in ChangeRecords) { FailCauserEMails = GUBPNode.MergeSpaceStrings(FailCauserEMails, Record.UserEmail); } } if (!String.IsNullOrEmpty(FailCauserEMails)) { NumPeople++; foreach (char AChar in FailCauserEMails.ToCharArray()) { if (AChar == ' ') { NumPeople++; } } if (NumPeople > 50) { EMailNote = String.Format("This step has been broken for more than 50 changes. It last succeeded at CL {0}. ", History.LastSucceeded); } } } else if (History.LastSucceeded <= 0) { EMailNote = String.Format("This step has been broken for more than a few days, so there is no record of it ever succeeding. "); } if (EMailNote != "" && !String.IsNullOrEmpty(History.FailedString)) { EMailNote += String.Format("It has failed at CLs {0}. ", History.FailedString); } if (EMailNote != "" && !String.IsNullOrEmpty(History.InProgressString)) { EMailNote += String.Format("These CLs are being built right now {0}. ", History.InProgressString); } if (History.LastSucceeded > 0 && History.LastSucceeded < P4Env.Changelist && History.LastFailed > History.LastSucceeded && History.LastFailed < P4Env.Changelist) { SendSuccessForGreenAfterRed = ParseParam("CIS"); } } if (History == null) { EC.UpdateEmailProperties(NodeToDo, 0, "", FailCauserEMails, EMailNote, SendSuccessForGreenAfterRed); } else { EC.UpdateEmailProperties(NodeToDo, History.LastSucceeded, History.FailedString, FailCauserEMails, EMailNote, SendSuccessForGreenAfterRed); } }