Exemple #1
0
        void SettingsForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            var config = new Configuration();
            config.JenkinsServerUrl = txtServer.Text.Trim();
            config.UserName = txtUsername.Text.Trim();
            config.Password = txtPassword.Text.Trim();
            config.JobNames.Add(txtJob.Text.Trim());

            config.Save();
        }
Exemple #2
0
        void SettingsForm_Load(object sender, EventArgs e)
        {
            var config = new Configuration();
            config = config.Load();

            txtServer.Text = config.JenkinsServerUrl;
            txtUsername.Text = config.UserName;
            txtPassword.Text = config.Password;
            if (config.JobNames.Count > 0)
            {
                txtJob.Text = config.JobNames.FirstOrDefault();
            }
        }
Exemple #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string message = string.Empty;
            try
            {
                timer1.Stop();

                var config = new Configuration().Load();

                // get latest build
                JenkinsJob job = JsonHelpers.GetJsonDataFor<JenkinsJob>(string.Format(@"/job/{0}", config.JobNames[0]));

                JenkinsJobDetails jobDetails = JsonHelpers.GetJsonDataFor<JenkinsJobDetails>(string.Format("/job/{0}/{1}", job.Name, job.LastBuild.Number));

                var causeJson = JsonConvert.SerializeObject(jobDetails.Actions[0]);
                jobDetails.Causes = JsonConvert.DeserializeObject<CausesObject>(causeJson);

                if (jobDetails == null || jobDetails.Result == null)
                {
                    return;
                }

                if (jobDetails.Result.Equals("FAILURE", StringComparison.InvariantCultureIgnoreCase) && this.LastBuildResult != BuildResults.FAILURE)
                {
                    this.LastBuildResult = BuildResults.FAILURE;
                    System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
                    this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Error")));

                    notifyIcon1.ShowBalloonTip(10000, "Build Failed", jobDetails.Causes.Causes[0].UserName + " broke the build.", ToolTipIcon.Error);
                    this.notifyIcon1.Text = "Butler says Last Build Failed by " + jobDetails.Causes.Causes[0].UserName;
                }
                if (jobDetails.Result.Equals("SUCCESS", StringComparison.InvariantCultureIgnoreCase) && this.LastBuildResult != BuildResults.SUCCESS)
                {
                    this.LastBuildResult = BuildResults.SUCCESS;
                    System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
                    this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));

                    notifyIcon1.ShowBalloonTip(10000, "Build Is now back to normal", "Build Is back to normal", ToolTipIcon.Info);
                    this.notifyIcon1.Text = "Butler says All builds are good!";
                }

                timer1.Start();
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    notifyIcon1.ShowBalloonTip(5000, "Invalid Jenkins Server or Job Name", message, ToolTipIcon.Error);
                }
                else
                {
                    timer1.Start();
                }
            }
        }