public void Dispose()
 {
     client = null;
     projectList = null;
     projects = null;
     buildConfigs = null;
 }
 public void Dispose()
 {
     client       = null;
     projectList  = null;
     projects     = null;
     buildConfigs = null;
 }
        public BuildMonitorRepository(string hostName)
        {
            client = new TeamCitySharp.TeamCityClient(hostName, false);

            projectList  = new List <ProjectModel>();
            projects     = GetAllProjects();
            buildConfigs = GetAllBuildConfigs();
        }
        public BuildMonitorRepository(string hostName)
        {
            client = new TeamCitySharp.TeamCityClient(hostName, false);

            projectList = new List<ProjectModel>();
            projects = GetAllProjects();
            buildConfigs = GetAllBuildConfigs();
        }
Esempio n. 5
0
        public IEnumerable<ProjectStatus> GetCurrentProjectStatus()
        {
            var url = System.Configuration.ConfigurationManager.AppSettings.GetValues("teamcity-hostname")?.FirstOrDefault();
            var username = System.Configuration.ConfigurationManager.AppSettings.GetValues("teamcity-username")?.FirstOrDefault();
            var pass = System.Configuration.ConfigurationManager.AppSettings.GetValues("teamcity-password")?.FirstOrDefault();            

            // https://github.com/y-gagar1n/TeamCitySharp
            var client = new TeamCitySharp.TeamCityClient(url);
            client.Connect(username, pass);
            var projects = client.Projects.All();

            var convertedProjects = this.ConvertProjects(client, projects);

            return convertedProjects;
        }
Esempio n. 6
0
        public IEnumerable <ProjectStatus> GetCurrentProjectStatus()
        {
            var url      = System.Configuration.ConfigurationManager.AppSettings.GetValues("teamcity-hostname")?.FirstOrDefault();
            var username = System.Configuration.ConfigurationManager.AppSettings.GetValues("teamcity-username")?.FirstOrDefault();
            var pass     = System.Configuration.ConfigurationManager.AppSettings.GetValues("teamcity-password")?.FirstOrDefault();

            // https://github.com/y-gagar1n/TeamCitySharp
            var client = new TeamCitySharp.TeamCityClient(url);

            client.Connect(username, pass);
            var projects = client.Projects.All();

            var convertedProjects = this.ConvertProjects(client, projects);

            return(convertedProjects);
        }
Esempio n. 7
0
        private IEnumerable <ProjectStatus> ConvertProjects(TeamCitySharp.TeamCityClient client, List <TeamCitySharp.DomainEntities.Project> projects)
        {
            var projectStatus = new List <ProjectStatus>();

            var configs = client.BuildConfigs.All();

            foreach (var config in configs)
            {
                var status = client.Builds.ByBuildConfigId(config.Id).FirstOrDefault();

                if (status != null)
                {
                    var project = projectStatus.FirstOrDefault(p => p.Name == config.ProjectName);
                    if (project == null)
                    {
                        project = new ProjectStatus()
                        {
                            Name = config.ProjectName
                        };
                        projectStatus.Add(project);
                    }

                    var item = new BuildType()
                    {
                        Name            = config.Name,
                        Status          = status.Status,
                        LastBuildNumber = status.Number,
                    };

                    var lastChange = client.Changes.LastChangeDetailByBuildConfigId(config.Id);
                    if (lastChange != null)
                    {
                        item.LastChangedBy = lastChange.Username;
                        var date = lastChange.Date;
                    }

                    project.BuildTypes.Add(item);
                }
            }

            return(projectStatus);
        }
Esempio n. 8
0
        public override SkillResponse Process(IntentRequest request)
        {
            var responseText = new StringBuilder();

            //We will use SSML as reponse format
            //https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html
            responseText.Append("<speak>");

            try
            {
                //let´s connect as guest on Teamcity Public instance!
                var client = new TeamCitySharp.TeamCityClient("teamcity.jetbrains.com", true);
                client.ConnectAsGuest();

                //By default, when a list of entities is requested, only basic fields are included into the response.
                //When a single entry is requested, all the fields are returned.
                //The complex field values can be returned in full or basic form, depending on a specific entity.
                //https://confluence.jetbrains.com/display/TCD18/REST+API#RESTAPI-FullandPartialResponses
                string projectNameToSearch = request.Intent.Slots["ProjectName"].Value;

                //We will do a similarity search in order to minimize spoken differences!
                //Cool Project: https://github.com/tylerjensen/duovia-fuzzystrings
                //To do so, let´s us get all available projects from Teamcity
                var project = client.Projects.All().OrderByDescending(item => item.Name.FuzzyMatch(projectNameToSearch)).FirstOrDefault();

                if (project != null)
                {
                    responseText.Append("<audio src = 'https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_positive_response_01.mp3'/>");
                    responseText.AppendFormat("Here is the Status of the {0} Project:", Ssml.SayAs(project.Name, "interjection"));
                    responseText.Append("<break/>");
                    #region Build Information
                    //Last Build informarion (we get only 1)
                    //state: <queued/running/finished>
                    //https://confluence.jetbrains.com/display/TCD18/REST+API
                    var lastBuilds = client.Builds.AffectedProject(project.Id, 1, new List <string>()
                    {
                        "state:finished"
                    });
                    if (lastBuilds.Any())
                    {
                        //We get by ID to load the full information!
                        var lastBuild = client.Builds.ById(lastBuilds.First().Id);

                        var triggeredBy = string.Empty;
                        if (lastBuild.Triggered.Type.Equals("schedule"))
                        {
                            triggeredBy = "automatically";
                        }
                        else if (lastBuild.Triggered.Type.Equals("vcs"))
                        {
                            triggeredBy = "by the " + Ssml.SayAs("Version Control System", "interjection");
                        }
                        else
                        {
                            triggeredBy = "by " + Ssml.SayAs(lastBuild.Triggered.User.Name, "interjection");
                        }

                        //let us find how long ago was the build
                        responseText.AppendFormat("Last Build, {0}, triggered {1}, happened {2}, {3}, with {4} status",
                                                  Ssml.SayAs(lastBuild.BuildType.Name, "interjection"),
                                                  triggeredBy,
                                                  Ssml.SayAs(lastBuild.FinishDate, true),
                                                  lastBuild.FinishDate.TimeAgo(),
                                                  Ssml.SayAs(lastBuild.Status, "interjection"));

                        responseText.Append("<break/>");

                        //Let´s collect statistics!
                        var buildStatistics = client.Statistics.GetByBuildId(lastBuild.Id);
                        //Default Statistics Values Provided by TeamCity
                        //https://confluence.jetbrains.com/display/TCD18/Custom+Chart#CustomChart-listOfDefaultStatisticValues
                        var failedTestCount = buildStatistics.FirstOrDefault(item => item.Name.Equals("FailedTestCount"));
                        var totalTestCount  = buildStatistics.FirstOrDefault(item => item.Name.Equals("TotalTestCount"));
                        if (totalTestCount != null)
                        {
                            if (failedTestCount != null)
                            {
                                int failed = Convert.ToInt32(failedTestCount);
                                int total  = Convert.ToInt32(totalTestCount);
                                if (failed > 0)
                                {
                                    responseText.AppendFormat("All {0} tests passed!", Ssml.SayAs(total));
                                }
                                else
                                {
                                    responseText.AppendFormat("{0} of {1} tests did not passed", Ssml.SayAs(Ssml.SayAs(failed), "interjection"), Ssml.SayAs(total));
                                }
                            }
                        }
                        else
                        {
                            responseText.Append("No automated Tests were executed");
                        }
                    }
                    else
                    {
                        responseText.AppendFormat("No Build Information found for {0}", projectNameToSearch);
                    }
                    #endregion
                }
                else
                {
                    responseText.AppendFormat("{0} not found", projectNameToSearch);
                }
                responseText.Append("<break/>");
                responseText.Append("That´s all. Bye.");
                responseText.Append("<audio src='https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_neutral_response_03.mp3'/>");
            }
            catch
            {
                responseText.Append("<audio src='https://s3.amazonaws.com/ask-soundlibrary/ui/gameshow/amzn_ui_sfx_gameshow_negative_response_02.mp3'/>");
                responseText.Append("<break/>");
                responseText.Append("ATTENTION: No connection to teamcity.");
                responseText.Append("<break/>");
            }

            responseText.Append("</speak>");
            SsmlOutputSpeech speech = new SsmlOutputSpeech();
            speech.Ssml = responseText.ToString();
            return(ResponseBuilder.Tell(speech));
        }