private void bDisableTillNextCommit_Click(object sender, EventArgs e) { //clear the failed build data in the monitor. //Reason - Say one build(A) is broken, other is fine(B). The alarm will start ringing //on the next commit of B. Such behaviour is not desired. //HudsonMonitor.ClearBuildData(); HudsonMonitor.beSilentTillNextCommit = true; //stop the alarm AlarmPlayer.Stop_Alarm(); }
private void bDiasble_Click(object sender, EventArgs e) { //first stop the alarm AlarmPlayer.Stop_Alarm(); //stop monitoring hudson also HudsonMonitor.isMonitoringEnabled = false; isMonitoring = false; bStartMon.Text = "Start Monitoring"; //convert the value to milli-seconds and start the timer AlarmTimer.Start(Convert.ToInt32(nAlarmPauseLength.Value) * 1000); }
private void cbEnableAlarm_CheckedChanged(object sender, EventArgs e) { //if the check box is enabled, enable the alarm if (cbEnableAlarm.Checked) { AlarmPlayer.isAlarmEnabled = true; } else { AlarmPlayer.isAlarmEnabled = false; AlarmPlayer.Stop_Alarm(); } }
public static void run() { log.Info("Monitoring started."); while (isMonitoringEnabled) { Console.WriteLine("\t ### #################### ### "); Console.WriteLine("\t ### Hudson Build Monitor ### "); Console.WriteLine("\t ### #################### ### "); Console.WriteLine(); //print the time Console.WriteLine("\t Current Time: " + DateTime.Now.ToString("h:mm:ss tt")); Console.WriteLine(); if (settings != null) { Console.Write("Name".PadRight(25)); Console.Write("Number".PadRight(10)); Console.Write("Status".PadRight(10)); Console.WriteLine(); Console.WriteLine(); foreach (string buildName in settings.AllKeys) { Build lastBuild = Check_Last_Build(settings[buildName]); Console.Write(buildName.PadRight(25)); Console.Write(lastBuild.buildNo.ToString().PadRight(10)); Console.Write(lastBuild.buildStatus.ToString().PadRight(10)); Console.WriteLine(); //if the status is not success if (!lastBuild.buildStatus.Equals(SUCCESS) && !lastBuild.buildStatus.Equals(BUILDING)) { log.Info("Build: " + buildName + " Number: " + lastBuild.buildNo + " - Build failed."); //add the build to the failed list if (!failedBuilds.ContainsKey(buildName)) { log.Info(" Build: " + buildName + " Number: " + lastBuild.buildNo + " - Added the build to the failed list."); failedBuilds.Add(buildName, lastBuild); } //if the alarm should keep silent till the next commit if (beSilentTillNextCommit) { log.Info("Build: " + buildName + " Number: " + lastBuild.buildNo + " - Be silent till next commit=True."); //if this is a new commit if (lastBuild.buildNo > failedBuilds[buildName].buildNo) { log.Info("Build: " + buildName + " Number: " + lastBuild.buildNo + " - Fails on next commit also, replaying alarm."); //play the alarm AlarmPlayer.Play_Alarm(); //reset the status beSilentTillNextCommit = false; } } else { log.Info("Build: " + buildName + " Number: " + lastBuild.buildNo + " - Build failed, playing alarm."); //play the alarm AlarmPlayer.Play_Alarm(); } } //if the status is success else { //check if the build has failed in the previous commit if (failedBuilds.ContainsKey(buildName)) { log.Info("Build: " + buildName + " Number: " + lastBuild.buildNo + " - Removing build form failed list."); //remove it from the failed list failedBuilds.Remove(buildName); //disable the alarm if no builds are failed now if (failedBuilds.Count == 0) { log.Info("Build: " + buildName + " Number: " + lastBuild.buildNo + " - All builds fine, disabling alarm."); AlarmPlayer.Stop_Alarm(); } } } } //refresh the output Console.SetCursorPosition(0, Console.CursorTop - (settings.Count + 8)); } Thread.Sleep(sleepLength); } //stop the alarm when stopping monitoring AlarmPlayer.Stop_Alarm(); log.Info("Monitoring stopped."); }