Ejemplo n.º 1
0
        /// <summary>
        /// Returns a downloaded artifact.
        /// </summary>
        /// <param name="artifactURI">The URI to the artifact (may contain a job number or a reference to latest)</param>
        /// <returns>A local reference to the artifact downloaded. It should not be modified!</returns>
        /// <remarks>
        /// If a reference is made to the "latestSuceessful" then the build server will be queried to find the latest successful
        /// job number. If the job number is for a file already downloaded, no download will occur. If the uri contains an explicit
        /// job number, and that file is already local for that job number, no web access will be made.
        /// 
        /// Files are stored in the user's temp directory. Deleting them at anytime is fine (as long as they aren't in direct use!!),
        /// as they will be automatically downloaded the next time a query is made.
        /// </remarks>
        static public async Task<FileInfo> GetArtifactFile(Uri artifactURI)
        {
            // Fetch access to the server
            var jenksInfo = new JenkinsServer(artifactURI);

            // Next, determine the job information for this guy
            var artifactInfo = await jenksInfo.GetArtifactInfo();

            // Build the file path where we will store it. If it is already there,
            // then we are done!
            var location = new FileInfo($"{Path.GetTempPath()}\\JenkinsArtifactCache\\{artifactInfo.JobName}\\{artifactInfo.BuildNumber}-{artifactInfo.ArtifactName}");
            if (location.Exists)
            {
                return location;
            }

            // If isn't there, then download it.
            await jenksInfo.Download(artifactInfo, location);
            location.Refresh();
            if (!location.Exists)
            {
                throw new InvalidOperationException($"Unable to download the Jenkins build artifact at the URL {artifactURI.OriginalString}.");
            }
            return location;
        }
Ejemplo n.º 2
0
        public void GetBuildDetailsAsync_ServiceAvailable_BuildReturned()
        {
            // Arrange
            var expected = new MockBuild {
                Number = _buildNumber
            };
            var expectedTask = new Task <Build>(() => expected);

            expectedTask.Start();

            // VS reports a compiler error here but tests run fine...
            _mockDataService.Expect(ds => ds.RequestAsync <Build>(Arg.Is(URL.Build), Arg.Is(_url), Arg.Is(_userName), Arg.Is(_apiKey), Arg <object[]> .List.ContainsAll(_buildNumberList)))
            .Return(expectedTask);
            //mockDataService.Expect(
            //    ds =>ds.RequestAsync<Node>(Arg.Is(URL.Api), Arg.Is(url), Arg.Is(userName), Arg.Is(apiKey),Arg<object[]>.Is.Anything));

            _targetServer = new JenkinsServer(_mockDataService, _url, _userName, _apiKey, _name);

            // Act
            var actualTask = _targetServer.GetBuildDetailsAsync(_jobName, _buildNumber);

            actualTask.Wait();
            var actual = actualTask.Result;

            // Assert
            Assert.AreEqual(actual, expected);
            _mockDataService.VerifyAllExpectations();
        }
Ejemplo n.º 3
0
        public async static Task ScheduleJob(string jobUrl, string jenkinsServerUri)
        {
            JenkinsServer server = SettingManager.GetJenkinsServer(jenkinsServerUri);

            if (server == null)
            {
                return;
            }

            using (WebClient client = new WebClient())
            {
                if (!string.IsNullOrWhiteSpace(server.UserName))
                {
                    // WebClient.Credentials can not be used, because those credentials will only be send to the server
                    // when the server responds with a challenge from the server. Jenkins won't send this challenge as documented
                    // on the wiki: https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients

                    // We should use the "old fashion" way of setting the header manually
                    string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", server.UserName, server.ApiToken)));
                    client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
                }

                var    jobUri     = new Uri(jobUrl);
                var    requestUri = new Uri(jobUri, "build");
                byte[] response   = await client.UploadValuesTaskAsync(requestUri, new NameValueCollection()
                {
                    { "delay", "0sec" }
                }
                                                                       );
            }
        }
        public static void RemoveServer(JenkinsServer server)
        {
            _serversCopy.Remove(server);
            SaveJenkinsServers();

            Settings.Default.SolutionJobs.RemoveAll((s) => string.Equals(server.Url, s.JenkinsServerUrl));
            Settings.Default.Save();
        }
Ejemplo n.º 5
0
        public static void RemoveServer(JenkinsServer server)
        {
            _serversCopy.Remove(server);
            SaveJenkinsServers();

            Settings.Default.SolutionJobs.RemoveAll((s) => string.Equals(server.Url, s.JenkinsServerUrl));
            Settings.Default.Save();
        }
        public static IEnumerable<ValidationResult> Validate(JenkinsServer server)
        {
            if (!string.IsNullOrWhiteSpace(server.UserName) && string.IsNullOrWhiteSpace(server.ApiToken))
            {
                return new[] { new ValidationResult() { Message = "You need to specify an API key too." } };
            }

            return Enumerable.Empty<ValidationResult>();
        }
Ejemplo n.º 7
0
 public void InitTests()
 {
     // Stub DataService and setupexpected return
     _mockDataService    = MockRepository.GenerateStub <IJenkinsDataService>();
     _targetServer       = new JenkinsServer(_mockDataService, _url, _userName, _apiKey, _name);
     _jobNameList[0]     = _jobName;
     _buildNumberList[0] = _buildNumber;
     _buildNumberList[1] = _jobName;
 }
        public static IEnumerable<ValidationResult> Validate(JenkinsServer editedServer)
        {
            var servers = ApiHandlerSettingsManager.GetServers();
            var equalServers = servers.Where((s) => string.Equals(editedServer.Name, s.Name, StringComparison.InvariantCultureIgnoreCase));
            if (equalServers.Any((s) => s != ViewModelController.BasicUserOptionsContentViewModel.SelectedJenkinsServer))
            {
                return new[] { new ValidationResult() { Message = "Server name must be unique." } };
            }

            return Enumerable.Empty<ValidationResult>();
        }
        public void JenkinsServer_Views()
        {
            // Arrange
            var jenkins = new JenkinsServer(this.jenkinsConnection);

            // Act
            List <JenkinsView> views = jenkins.Views();

            // Assert
            Assert.AreNotEqual(0, views.Count);
        }
        public void JenkinsServer_Jobs()
        {
            // Arrange
            var jenkins = new JenkinsServer(this.jenkinsConnection);

            // Act
            List <JenkinsJob> jobs = jenkins.Jobs();

            // Assert
            Assert.AreNotEqual(0, jobs.Count);
        }
Ejemplo n.º 11
0
        public void LoginFailureTest()
        {
            // Arrange

            // Act
            using (JenkinsServer jenkins = new JenkinsServer(this.host, this.login, "aaaaaaaaaaaaaaaa"))
            {
            }

            // Assert
            Assert.IsNotNull(null);
        }
        public static IEnumerable <ValidationResult> Validate(JenkinsServer server)
        {
            if (!string.IsNullOrWhiteSpace(server.UserName) && string.IsNullOrWhiteSpace(server.ApiToken))
            {
                return(new[] { new ValidationResult()
                               {
                                   Message = "You need to specify an API key too."
                               } });
            }

            return(Enumerable.Empty <ValidationResult>());
        }
        public BasicUserOptionsContentViewModel()
        {
            _editJenkinsServer = new JenkinsServer();

            AddServer = new RelayCommand(HandleAddJenkinsServer);
            RemoveServer = new RelayCommand(HandleRemoveJenkinsServer);
            ApplyChanges = new RelayCommand(HandleApplyChanges, CanExecuteApplyChanges);

            JenkinsServers = ApiHandlerSettingsManager.GetServers();
            SelectedJenkinsServer = JenkinsServers.FirstOrDefault();

            InitializeValidationRules();
        }
Ejemplo n.º 14
0
        private void HandleAddJenkinsServer()
        {
            var newJenkinsServer = new JenkinsServer()
            {
                Name = "New server", Url = "http://"
            };

            ApiHandlerSettingsManager.AddServer(newJenkinsServer);

            SelectedJenkinsServer = newJenkinsServer;

            UpdateEditJenkinsServer();
        }
Ejemplo n.º 15
0
        public BasicUserOptionsContentViewModel()
        {
            _editJenkinsServer = new JenkinsServer();

            AddServer    = new RelayCommand(HandleAddJenkinsServer);
            RemoveServer = new RelayCommand(HandleRemoveJenkinsServer);
            ApplyChanges = new RelayCommand(HandleApplyChanges, CanExecuteApplyChanges);

            JenkinsServers        = ApiHandlerSettingsManager.GetServers();
            SelectedJenkinsServer = JenkinsServers.FirstOrDefault();

            InitializeValidationRules();
        }
Ejemplo n.º 16
0
        public void JenkinsServer_ConstructedSuccessfully()
        {
            // Arrange

            // Act
            _targetServer = new JenkinsServer(_url, _userName, _apiKey, _name);

            // Assert
            Assert.IsInstanceOfType(_targetServer, typeof(JenkinsServer));
            Assert.AreEqual(_targetServer.Url, _url);
            Assert.AreEqual(_targetServer.UserName, _userName);
            Assert.AreEqual(_targetServer.ApiKey, _apiKey);
            Assert.AreEqual(_targetServer.Name, _name);
        }
Ejemplo n.º 17
0
        private void UpdateEditJenkinsServer()
        {
            JenkinsServer server = SelectedJenkinsServer;

            ;
            if (SelectedJenkinsServer == null)
            {
                server = new JenkinsServer();
            }

            EditJenkinsServer.Name     = server.Name;
            EditJenkinsServer.Url      = server.Url;
            EditJenkinsServer.UserName = server.UserName;
            EditJenkinsServer.ApiToken = server.ApiToken;
        }
        public static IEnumerable <ValidationResult> Validate(JenkinsServer editedServer)
        {
            var servers      = ApiHandlerSettingsManager.GetServers();
            var equalServers = servers.Where((s) => string.Equals(editedServer.Name, s.Name, StringComparison.InvariantCultureIgnoreCase));

            if (equalServers.Any((s) => s != ViewModelController.BasicUserOptionsContentViewModel.SelectedJenkinsServer))
            {
                return(new[] { new ValidationResult()
                               {
                                   Message = "Server name must be unique."
                               } });
            }

            return(Enumerable.Empty <ValidationResult>());
        }
Ejemplo n.º 19
0
        public static void UpdateServer(
            JenkinsServer originalJenkinsServer,
            JenkinsServer newJenkinsServer)
        {
            if (!_serversCopy.Contains(originalJenkinsServer))
            {
                return;
            }

            originalJenkinsServer.Name     = newJenkinsServer.Name;
            originalJenkinsServer.Url      = newJenkinsServer.Url;
            originalJenkinsServer.UserName = newJenkinsServer.UserName;
            originalJenkinsServer.ApiToken = newJenkinsServer.ApiToken;

            SaveJenkinsServers();
        }
Ejemplo n.º 20
0
        public async static Task <T> GetFromJSONData <T>(JenkinsServer server, Uri jsonDataUri) where T : class
        {
            T deserialisedJsonObject = null;

            using (WebClient wc = CreateJenkinsWebClient(server))
            {
                Task <string> jsonRawDataTask = wc.DownloadStringTaskAsync(jsonDataUri);

                if (await Task.WhenAny(jsonRawDataTask, Task.Delay(30000)) == jsonRawDataTask)
                {
                    deserialisedJsonObject = JsonConvert.DeserializeObject <T>(jsonRawDataTask.Result);
                }
            }

            return(deserialisedJsonObject);
        }
        public static Task <IEnumerable <ValidationResult> > Validate(JenkinsServer server)
        {
            return(Task.Factory.StartNew(() =>
            {
                if (string.IsNullOrWhiteSpace(server.Url))
                {
                    return Enumerable.Empty <ValidationResult>();
                }

                if (!JenkinsServerValidator.IsJenkinsServer(server.Url))
                {
                    return new[] { new ValidationResult()
                                   {
                                       Message = "Url is not a valid Jenkins server."
                                   } };
                }

                var version = JenkinsServerValidator.GetJenkinsVersion(server.Url);

                if (!JenkinsServerValidator.IsMinimumRequiredVersion(server.Url))
                {
                    return new[] {
                        new ValidationResult()
                        {
                            Message = string.Format(
                                "You need at least Jenkins version {0} (found {1}).",
                                JenkinsServerValidator.MINIMUM_VERSION, version)
                        }
                    };
                }

                if (!JenkinsServerValidator.RangeSpecifierSupported(server.Url))
                {
                    return new[] {
                        new ValidationResult()
                        {
                            ValidationResultType = ValidationResultType.Warning,
                            Message = string.Format(
                                "Data loading can be slow on this Jenkins version, please upgrade to version {0} to fix this.",
                                JenkinsServerValidator.RANGE_SPECIFIER_VERSION)
                        }
                    };
                }

                return Enumerable.Empty <ValidationResult>();
            }));
        }
Ejemplo n.º 22
0
        public void LoginSuccessTest()
        {
            // Arrange
            Uri    serverUrl;
            string serverDescription;

            // Act
            using (JenkinsServer jenkins = new JenkinsServer(this.host, this.login, this.password))
            {
                serverUrl         = jenkins.Url;
                serverDescription = jenkins.Description;
            }

            // Assert
            Assert.AreEqual(this.host, serverUrl, nameof(serverUrl));
            Assert.AreEqual("Hello World", serverDescription, nameof(serverDescription));
        }
        public static async Task <IEnumerable <JenkinsView> > GetViews(JenkinsServer server)
        {
            Uri             serverUri   = new Uri(server.Url);
            Uri             viewInfoUri = new Uri(serverUri, VIEW_QUERY);
            JenkinsOverview overview    = await GetFromJSONData <JenkinsOverview>(server, viewInfoUri);

            if (overview == null)
            {
                overview = new JenkinsOverview();
            }

            foreach (var view in overview.Views)
            {
                view.Url = FixPrimaryViewUrl(view);
            }

            return(overview.Views);
        }
Ejemplo n.º 24
0
        public async static Task<string> GetLatestLog(string jobUrl, JenkinsServer jenkinsServer)
        {
            string logData = null;
            using (WebClient client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServer))
            {
                var latestLogUri = CreateLatestLogUri(jobUrl);
                logData = await client.DownloadStringTaskAsync(latestLogUri);
            }

            string fileName = null;
            if (!string.IsNullOrWhiteSpace(logData))
            {
                fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt";
                File.WriteAllText(fileName, logData);
            }

            return fileName;
        }
        private static bool RemoveServerFromUserConfig(JenkinsServer Server)
        {
            XmlDocument UserConfig = new XmlDocument();

            try
            {
                UserConfig.Load(ApplicationVariables.UserConfigFilePath);
            }
            catch
            {
                return(false);
            }

            XmlNodeList ServerNodes = UserConfig.SelectNodes(@"userconfig/configuredservers/server");

            if (ServerNodes == null || ServerNodes.Count == 0)
            {
                return(false);
            }

            foreach (XmlNode ServerNode in ServerNodes)
            {
                if (ServerNode.Attributes["id"].Value == Server.id &&
                    ServerNode.Attributes["name"].Value == Server.name &&
                    ServerNode.Attributes["url"].Value == Server.url)
                {
                    XmlNode ConfiguredServers = UserConfig.SelectSingleNode(@"userconfig/configuredservers");
                    ConfiguredServers.RemoveChild(ServerNode);

                    try
                    {
                        UserConfig.Save(ApplicationVariables.UserConfigFilePath);

                        return(true);
                    }
                    catch
                    {
                        return(false);
                    }
                }
            }

            return(false);
        }
        public static async Task <IEnumerable <JenkinsJob> > GetJobsFromView(JenkinsServer server, JenkinsView view)
        {
            Uri viewUri = new Uri(view.Url);

            var rangeSpecifierSupported = JenkinsServerValidator.RangeSpecifierSupported(server.Url);
            var jobsQuery = rangeSpecifierSupported ? JOBS_QUERY_WITH_RANGE : JOBS_QUERY;

            Uri         jobsInfoUri     = new Uri(viewUri, jobsQuery);
            JenkinsView viewWithJobData = await GetFromJSONData <JenkinsView>(server, jobsInfoUri);

            var result = viewWithJobData == null?Enumerable.Empty <JenkinsJob>() : viewWithJobData.Jobs;

            if (!rangeSpecifierSupported)
            {
                RestrictNumberOfJobBuilds(result);
            }

            return(result);
        }
        public static WebClient CreateJenkinsWebClient(JenkinsServer server)
        {
            WebClient client = new WebClient();

            client.UseDefaultCredentials = true;

            if (server != null && !string.IsNullOrWhiteSpace(server.UserName))
            {
                // WebClient.Credentials can not be used, because those credentials will only be send to the server
                // when the server responds with a challenge from the server. Jenkins won't send this challenge as documented
                // on the wiki: https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients

                // We should use the "old fashion" way of setting the header manually
                string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", server.UserName, server.ApiToken)));
                client.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
            }

            return(client);
        }
        private static bool AddServerToUserConfig(JenkinsServer Server)
        {
            XmlDocument UserConfig = new XmlDocument();

            try
            {
                UserConfig.Load(ApplicationVariables.UserConfigFilePath);
            }
            catch
            {
                return(false);
            }

            XmlElement   ServerElement = UserConfig.CreateElement("server");
            XmlAttribute IdAttribute   = UserConfig.CreateAttribute("id");

            IdAttribute.Value = Server.id;
            XmlAttribute NameAttribute = UserConfig.CreateAttribute("name");

            NameAttribute.Value = Server.name;
            XmlAttribute UrlAttribute = UserConfig.CreateAttribute("url");

            UrlAttribute.Value = Server.url;

            ServerElement.Attributes.Append(IdAttribute);
            ServerElement.Attributes.Append(NameAttribute);
            ServerElement.Attributes.Append(UrlAttribute);

            XmlNode ConfiguredServers = UserConfig.SelectSingleNode(@"userconfig/configuredservers");

            ConfiguredServers.AppendChild(ServerElement);

            try
            {
                UserConfig.Save(ApplicationVariables.UserConfigFilePath);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public static Task<IEnumerable<ValidationResult>> Validate(JenkinsServer server)
        {
            return Task.Factory.StartNew(() =>
                {
                    if (string.IsNullOrWhiteSpace(server.Url))
                    {
                        return Enumerable.Empty<ValidationResult>();
                    }

                    if (!JenkinsServerValidator.IsJenkinsServer(server.Url))
                    {
                        return new[] { new ValidationResult() { Message = "Url is not a valid Jenkins server." } };
                    }

                    var version = JenkinsServerValidator.GetJenkinsVersion(server.Url);

                    if (!JenkinsServerValidator.IsMinimumRequiredVersion(server.Url))
                    {
                        return new[] { 
                            new ValidationResult() { 
                                Message = string.Format(
                                    "You need at least Jenkins version {0} (found {1}).", 
                                    JenkinsServerValidator.MINIMUM_VERSION, version)
                            }
                        };
                    }

                    if (!JenkinsServerValidator.RangeSpecifierSupported(server.Url))
                    {
                        return new[] { 
                            new ValidationResult() { 
                                ValidationResultType = ValidationResultType.Warning,
                                Message = string.Format(
                                    "Data loading can be slow on this Jenkins version, please upgrade to version {0} to fix this.", 
                                    JenkinsServerValidator.RANGE_SPECIFIER_VERSION)
                            }
                        };
                    }

                    return Enumerable.Empty<ValidationResult>();
                });
        }
        public async static Task <string> GetLatestLog(string jobUrl, JenkinsServer jenkinsServer)
        {
            string logData = null;

            using (WebClient client = JenkinsDataLoader.CreateJenkinsWebClient(jenkinsServer))
            {
                var latestLogUri = CreateLatestLogUri(jobUrl);
                logData = await client.DownloadStringTaskAsync(latestLogUri);
            }

            string fileName = null;

            if (!string.IsNullOrWhiteSpace(logData))
            {
                fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".txt";
                File.WriteAllText(fileName, logData);
            }

            return(fileName);
        }
Ejemplo n.º 31
0
        public async Task <JenkinsServer> GetServerAsync(string url, bool depthLoad)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            var server = new JenkinsServer {
                Url = url
            };

            server.Node = await this.restManager.LoadAsync <JenkinsNode>(server.NodeRestUrl);

            if (depthLoad && server.Node != null)
            {
                var users = await this.restManager.LoadAsync <JenkinsServer>(server.UsersRestUrl);

                if (server.Node.Jobs != null)
                {
                    server.Node.Jobs = server.Node.Jobs.Select(j => this.GetJobAsync(j.RestUrl, true).Result).ToArray();
                }

                if (server.Node.JenkinsViews != null)
                {
                    server.Node.JenkinsViews = server.Node.JenkinsViews.Select(v => this.GetViewAsync(v.DetailsUrl, true).Result).ToArray();

                    if (server.Node.PrimaryJenkinsView != null)
                    {
                        server.Node.PrimaryJenkinsView = server.Node.JenkinsViews.FirstOrDefault(v => string.Equals(v.Url, server.Node.PrimaryJenkinsView.Url, StringComparison.OrdinalIgnoreCase));
                    }
                }

                server.Users = users == null ? null : users.Users;
            }

            return(server);
        }
Ejemplo n.º 32
0
        private async static Task <JenkinsView> GetJenkinsView(string jenkinsServerUrl, string viewUrl)
        {
            JenkinsView view = null;

            JenkinsServer server = SettingManager.GetJenkinsServer(jenkinsServerUrl);

            if (server == null)
            {
                return(null);
            }

            using (WebClient wc = new WebClient())
            {
                if (!string.IsNullOrWhiteSpace(server.UserName))
                {
                    // WebClient.Credentials can not be used, because those credentials will only be send to the server
                    // when the server responds with a challenge from the server. Jenkins won't send this challenge as documented
                    // on the wiki: https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients

                    // We should use the "old fashion" way of setting the header manually
                    string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", server.UserName, server.ApiToken)));
                    wc.Headers[HttpRequestHeader.Authorization] = "Basic " + credentials;
                }

                Uri baseUri = new Uri(viewUrl);

                Task <string> jsonRawDataTask = wc.DownloadStringTaskAsync(new Uri(baseUri, "api/json?pretty=true"));

                if (await Task.WhenAny(jsonRawDataTask, Task.Delay(3000)) == jsonRawDataTask)
                {
                    view = JsonConvert.DeserializeObject <JenkinsView>(jsonRawDataTask.Result);
                }
            }

            return(view ?? new JenkinsView());
        }
        private static List <JenkinsServer> LoadConfiguredServersFromUserConfig()
        {
            List <JenkinsServer> Servers = new List <JenkinsServer>();

            XmlDocument UserConfig = new XmlDocument();

            try
            {
                UserConfig.Load(ApplicationVariables.UserConfigFilePath);
            }
            catch
            {
                return(Servers);
            }

            XmlNodeList ServerNodes = UserConfig.SelectNodes(@"userconfig/configuredservers/server");

            if (ServerNodes == null || ServerNodes.Count == 0)
            {
                return(Servers);
            }

            foreach (XmlNode ServerNode in ServerNodes)
            {
                JenkinsServer Server = new JenkinsServer()
                {
                    id   = ServerNode.Attributes["id"].Value,
                    name = ServerNode.Attributes["name"].Value,
                    url  = ServerNode.Attributes["url"].Value
                };

                Servers.Add(Server);
            }

            return(Servers);
        }
 private void SelectNewJenkinsServer(JenkinsServer value, string preferredViewName = null)
 {
     _selectedJenkinsServer = value;
     RaisePropertyChanged(() => SelectedJenkinsServer);
     RefreshViews(preferredViewName);
 }
        public static void UpdateServer(
            JenkinsServer originalJenkinsServer,
            JenkinsServer newJenkinsServer)
        {
            if (!_serversCopy.Contains(originalJenkinsServer))
            {
                return;
            }

            originalJenkinsServer.Name = newJenkinsServer.Name;
            originalJenkinsServer.Url = newJenkinsServer.Url;
            originalJenkinsServer.UserName = newJenkinsServer.UserName;
            originalJenkinsServer.ApiToken = newJenkinsServer.ApiToken;

            SaveJenkinsServers();
        }
 public static void AddServer(JenkinsServer server)
 {
     _serversCopy.Add(server);
     SaveJenkinsServers();
 }
 private void SelectNewJenkinsServer(JenkinsServer value, string preferredViewName = null)
 {
     _selectedJenkinsServer = value;
     RaisePropertyChanged(() => SelectedJenkinsServer);
     RefreshViews(preferredViewName);
 }
 public static IEnumerable <ValidationResult> Validate(JenkinsServer server)
 {
     return(new[] { new ResetValidationResult("ApiToken") });
 }
        private void HandleAddJenkinsServer()
        {
            var newJenkinsServer = new JenkinsServer() { Name = "New server", Url = "http://" };

            ApiHandlerSettingsManager.AddServer(newJenkinsServer);

            SelectedJenkinsServer = newJenkinsServer;

            UpdateEditJenkinsServer();
        }
        private void UpdateEditJenkinsServer()
        {
            JenkinsServer server = SelectedJenkinsServer;
            ;
            if (SelectedJenkinsServer == null)
            {
                server = new JenkinsServer();
            }

            EditJenkinsServer.Name = server.Name;
            EditJenkinsServer.Url = server.Url;
            EditJenkinsServer.UserName = server.UserName;
            EditJenkinsServer.ApiToken = server.ApiToken;
        }
        public static WebClient CreateJenkinsWebClient(string jenkinsServerUrl)
        {
            JenkinsServer server = ApiHandlerSettingsManager.GetJenkinsServer(jenkinsServerUrl);

            return(CreateJenkinsWebClient(server));
        }
Ejemplo n.º 42
0
 public static void AddServer(JenkinsServer server)
 {
     _serversCopy.Add(server);
     SaveJenkinsServers();
 }
 public static IEnumerable<ValidationResult> Validate(JenkinsServer server)
 {
     return new[] { new ResetValidationResult("ApiToken") };
 }