예제 #1
0
        public void ServerTest()
        {
            JenkinsModelHudson server = null;

            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                server = jenkins.GetServerAsync().Result;
            }

            Assert.IsNotNull(server);
            Assert.IsNotNull(server.AssignedLabels, "assignedLabels");

            //Assert.AreEqual(this.serverMode, server.Mode, "mode");
            Assert.AreEqual("the master Jenkins node", server.NodeDescription, "nodeDescription");
            Assert.AreEqual("", server.NodeName, "nodeName");
            Assert.AreEqual(4, server.NumExecutors, "numExecutors");
            Assert.AreEqual(null, server.Description, "description");

            Assert.IsNotNull(server.Jobs, "jobs");

            Assert.IsNotNull(server.OverallLoad, "overallLoad");

            Assert.IsNotNull(server.PrimaryView, "primaryView");

            Assert.AreEqual(-1, server.SlaveAgentPort, "slaveAgentPort");
            Assert.AreEqual(true, server.UseCrumbs, "useCrumbs");
            Assert.AreEqual(true, server.UseSecurity, "useSecurity");

            Assert.IsNotNull(server.Views, "views");

            Assert.AreEqual("", server.NodeName, "nodeName");
        }
        public void ServerTest()
        {
            // Arrange
            JenkinsModelHudson server = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                server = jenkins.GetServerAsync().Result;
            }

            // Assert
            Assert.IsNotNull(server, nameof(server));
            Assert.AreEqual("hudson.model.Hudson", server.Class, nameof(server.Class));

            Assert.AreEqual("Hello World", server.Description, nameof(server.Description));
            Assert.AreEqual(0, server.SlaveAgentPort, nameof(server.SlaveAgentPort));
            Assert.AreEqual($"{this.host}", server.Url, nameof(server.Url));
            Assert.AreEqual(true, server.UseCrumbs, nameof(server.UseCrumbs));
            Assert.AreEqual(true, server.UseSecurity, nameof(server.UseSecurity));

            Assert.AreEqual(JenkinsModelNodeMode.Normal, server.Mode, nameof(server.Mode));
            Assert.AreEqual("the master Jenkins node", server.NodeDescription, nameof(server.NodeDescription));
            Assert.AreEqual("", server.NodeName, nameof(server.NodeName));
            Assert.AreEqual(1, server.NumExecutors, nameof(server.NumExecutors));

            Assert.IsNotNull(server.AssignedLabels, nameof(server.AssignedLabels));
            Assert.IsNotNull(server.Jobs, nameof(server.Jobs));
            Assert.IsNotNull(server.OverallLoad, nameof(server.OverallLoad));
            Assert.IsNotNull(server.PrimaryView, nameof(server.PrimaryView));
            Assert.IsNotNull(server.Views, nameof(server.Views));
        }
        public void LoginEmptyTest()
        {
            // Arrange
            JenkinsModelHudson server = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host))
            {
                server = jenkins.GetServerAsync().Result;
            }

            // Assert
        }
        public void LoginFailedTest()
        {
            // Arrange
            JenkinsModelHudson server = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, "Mustermann", "Max"))
            {
                server = jenkins.GetServerAsync().Result;
            }

            // Assert
        }
        public void LoginTokenTest()
        {
            // Arrange
            JenkinsModelHudson server = null;
            JenkinsModelUser   user   = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.token))
            {
                server = jenkins.GetServerAsync().Result;
                user   = jenkins.GetCurrentUserAsync().Result;
            }

            // Assert
            Assert.IsNotNull(server);
            Assert.IsNotNull(user);
            Assert.AreEqual(login, user.FullName, nameof(user.FullName));
        }
예제 #6
0
        /// <summary>
        /// Check if job exists.
        /// </summary>
        /// <param name="jobName">Name of the job to check.</param>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>True if job exists. False if not.</returns>
        public async Task <bool> JobExists(string jobName, CancellationToken cancellationToken)
        {
            JenkinsModelHudson server = await GetApiAsync <JenkinsModelHudson>("", cancellationToken);

            return(server.Jobs.Any(j => j.Name == jobName));
        }
예제 #7
0
        /// <summary>
        /// Get the Jenkins server configuration.
        /// </summary>
        /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
        /// <returns>Jenkins server configuration</returns>
        public async Task <JenkinsModelHudson> GetServerAsync(CancellationToken cancellationToken)
        {
            JenkinsModelHudson server = await GetApiAsync <JenkinsModelHudson>("", cancellationToken);

            return(server);
        }