Esempio n. 1
0
        public void Execute(Bot bot)
        {
            if (string.IsNullOrWhiteSpace(IpAddressOrHostNameOfCCServer) || !Projects.Any()) return;

            _client = new TeamCityClient(IpAddressOrHostNameOfCCServer);
            _client.Connect("teamcitysharpuser", "qwerty");

            var allProjects = _client.AllProjects();
            var allBuildConfigs = _client.AllBuildConfigs();

            foreach (var proj in allProjects)
            {
                Project currentProject = proj;
                var buildConfigs = allBuildConfigs.Where(buildConfig => currentProject.Id == buildConfig.Project.Id);

                foreach (var currentBuildConfig in buildConfigs)
                {
                    var build = _client.LastBuildByBuildConfigId(currentBuildConfig.Id);

                    var project = new ProjectModel(currentProject.Name, currentProject.Id, currentBuildConfig.Name, build.StartDate,
                                                     build.Status, build.StatusText);
                    Update(bot, project);
                }
            }
        }
        public TeamCityRestApiClient(TeamCityHostConnectionDetails connectionDetails)
        {
            if (connectionDetails == null) { throw new ArgumentNullException("connectionDetails"); }
            this.connectionDetails = connectionDetails;

            this.client = new TeamCityClient(connectionDetails.Host);
        }
 public void Dispose()
 {
     client = null;
     projectList = null;
     projects = null;
     buildConfigs = null;
 }
Esempio n. 4
0
        private TeamCityClient Open(Uri uri)
        {
            var client = new TeamCityClient(string.Concat(uri.Host,":", uri.Port), (string.Compare(uri.Scheme, "https")==0));
            client.Connect(this.Username, this.Password);

            return client;
        }
        public BuildMonitorRepository(string hostName)
        {
            client = new TeamCityClient(hostName, false);

            projectList = new List<ProjectModel>();
            projects = GetAllProjects();
            buildConfigs = GetAllBuildConfigs();
        }
        public ScreenSaver()
        {
            InitializeComponent();
            mDelay = Settings.Default.Delay;
            mUrlPath = Settings.Default.ImgPath;
            mPort = Settings.Default.PortPath;
            mUserName = Settings.Default.Username;
            mPassword = Settings.Default.Password;
            mClient = new TeamCityClient(mUrlPath + ":" + mPort);
            mClient.Connect(mUserName, mPassword);
            LoadProjects();
            mProjectsLoaded = true;

            ProjectsCtrl.ProjectsItemsCtrl.DataContext = ProjectList;
            ProjectsCtrl.ProjectsItemsCtrl.ItemsSource = ProjectList.Items;
            ProjectsCtrl.InitProjectsControl(ProjectList);
        }
        public bool Connect()
        {
            try
            {
                client = new TeamCityClient(teamcityUrl + portNumber);
                client.Connect(userName, password);
                Projects = client.Projects.All();

                observableTeamcityConnectionService = Observable.Timer(TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(scanRate));
                onlineSubscription = observableTeamcityConnectionService.Subscribe(CheckTeamCityApi);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                return false;
            }

            return true;
        }
        /// <summary>
        /// Initialises this component
        /// </summary>
        /// <param name="settings">The settings collection.</param>
        public void Initialise(string name, Settings settings)
        {
            FileLogger.Logger.LogInformation("Initialising Monitor: {0}", name);
            if (settings == null || settings.Setting.Count == 0) throw new ApplicationException("No settings provided. This is required to Initialise the component.");
            Name = name;

            // Get the parameters for the TeamCity Connection
            // --------------------------------------------------------------------------------------
            var hostName = settings["Host"] as string;
            if (string.IsNullOrEmpty(hostName)) throw new ApplicationException("Host setting must be specified.");

            var username = settings.Get("User","guest");
            var password = settings.Get("Password","guest");
            var isGuest  = settings.Get("UseGuest",true);

            // Attempt to connect to TeamCity
            // --------------------------------------------------------------------------------------
            try {
                _client = new TeamCityClient(hostName);
                _client.Connect(username, password, isGuest);
            } catch (Exception ex) {
                throw new ApplicationException("Could not connect to TeamCity using the provided credentials.", ex);
            }

            // Build the list of Builds/Projects that we will be monitoring for THIS monitor
            // -----------------------------------------------------------------------------
            _builds = BuildMonitorProjects(settings);
            if (_builds == null || _builds.Count == 0) throw new ApplicationException("No Builds specified to Monitor.");

            IsInitialised = true;
        }
Esempio n. 9
0
        public static TeamCityClient GetClient()
        {
            TeamCityClient client;
            Uri uri;
            if (Uri.TryCreate(Current.Settings.TeamCity.Url, UriKind.Absolute, out uri))
                client = new TeamCityClient(uri.Host, useSsl: uri.Scheme == Uri.UriSchemeHttps);
            else
                client = new TeamCityClient(Current.Settings.TeamCity.Url, useSsl: false);

            client.Connect(Current.Settings.TeamCity.User, Current.Settings.TeamCity.Password);
            return client;
        }
 public TeamCityClient CreateClient()
 {
     var client = new TeamCityClient(Url);
     client.Connect(Username, Password, Guest);
     return client;
 }
 public ArtifactDownloader(TeamCityClient client, string targetPath, IEnumerable<ArtifactModel> artifacts)
 {
     this.client = client;
     this.targetPath = targetPath;
     this.artifacts = artifacts.ToArray();
 }
Esempio n. 12
0
 public static TeamCityClient GetClient()
 {
     var client = new TeamCityClient(Current.Settings.TeamCity.Url, useSsl: true);
     client.Connect(Current.Settings.TeamCity.User, Current.Settings.TeamCity.Password);
     return client;
 }
 public TeamCityRepository(string hostname, string username, string password)
 {
     this.username = username;
     this.password = password;
     this.client = new TeamCityClient(hostname);
 }
 public InteractiveArtifactDownloader(TeamCityClient client, Worker worker)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
     if (worker == null)
     {
         throw new ArgumentNullException("worker");
     }
     this.client = client;
     this.worker = worker;
 }