Esempio n. 1
0
        private OS GetOsForBuild(BuildId buildId)
        {
            var json     = _client.GetJson(JenkinsUtil.GetBuildPath(buildId), tree: "builtOn[*]");
            var computer = json.Value <string>("builtOn");
            OS  os;

            if (!string.IsNullOrEmpty(computer) && _computerNameMap.TryGetValue(computer, out os))
            {
                return(os);
            }

            return(OS.Unknown);
        }
Esempio n. 2
0
        private bool AddServer(string serverUri, bool authRequired = false, bool promptCreds = true)
        {
            if (m_servers.Any(x => x.DomainUrl == serverUri))
            {
                return(false);
            }

            UserCredentials userCreds = null;

            if (authRequired)
            {
                userCreds = PromptForCredentials(serverUri, promptCreds);
                if (userCreds == null)
                {
                    MessageBox.Show("Please check your username and password", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
            }

            ServerViewModel serverViewModel;

            try
            {
                JenkinsClient client = new JenkinsClient(new Uri(serverUri, UriKind.Absolute), userCreds);
                Server        server = client.GetJson <Server>(new Uri(serverUri));
                server.RequiresAuthentication = authRequired;

                serverViewModel = new ServerViewModel(client, server);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message ?? ex.InnerException?.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            SavedJenkinsServers savedServer = m_settings.Servers.FirstOrDefault(x => x.DomainUrl == serverViewModel.DomainUrl);

            foreach (JobViewModel job in serverViewModel.Jobs)
            {
                if (savedServer != null)
                {
                    job.IsSubscribed = savedServer.Jobs.Any(x => x.Name == job.Name);
                }
                job.StatusChanged += JobOnStatusChanged;
            }

            m_servers.Add(serverViewModel);

            SaveSettings();
            return(true);
        }
Esempio n. 3
0
        private bool AddServer(string serverUri)
        {
            if (m_servers.Any(x => x.DomainUrl == serverUri))
            {
                return(false);
            }

            ServerViewModel serverViewModel;

            try
            {
                JenkinsClient client = new JenkinsClient(new Uri(serverUri, UriKind.Absolute));
                Server        server = client.GetJson <Server>(new Uri(serverUri));

                serverViewModel = new ServerViewModel(client, server);
            }
            catch (Exception)
            {
                return(false);
            }

            SavedJenkinsServers savedServer = m_settings.Servers.FirstOrDefault(x => x.DomainUrl == serverViewModel.DomainUrl);

            foreach (JobViewModel job in serverViewModel.Jobs)
            {
                if (savedServer != null)
                {
                    job.IsSubscribed = savedServer.Jobs.Any(x => x.Name == job.Name);
                }
                job.StatusChanged += JobOnStatusChanged;
            }

            m_servers.Add(serverViewModel);

            return(true);
        }
Esempio n. 4
0
		private bool AddServer(string serverUri)
		{
			if (m_servers.Any(x => x.DomainUrl == serverUri))
				return false;

			ServerViewModel serverViewModel;
			try
			{
				JenkinsClient client = new JenkinsClient(new Uri(serverUri, UriKind.Absolute));
				Server server = client.GetJson<Server>(new Uri(serverUri));

				serverViewModel = new ServerViewModel(client, server);
			}
			catch (Exception)
			{
				return false;
			}

			SavedJenkinsServers savedServer = m_settings.Servers.FirstOrDefault(x => x.DomainUrl == serverViewModel.DomainUrl);

			foreach (JobViewModel job in serverViewModel.Jobs)
			{
				if (savedServer != null)
					job.IsSubscribed = savedServer.Jobs.Any(x => x.Name == job.Name);
				job.StatusChanged += JobOnStatusChanged;
			}

			m_servers.Add(serverViewModel);

			return true;
		}