Exemplo n.º 1
0
        public void JobConfigTest()
        {
            // Arrange
            string orgConfig = null;
            string updConfig = null;
            string cngConfig = null;
            string descOrg   = null;
            string descCng   = null;

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                orgConfig = jenkins.GetJobConfigAsync("FreestyleConfig").Result;
                descOrg   = GetConfigDescription(orgConfig);

                cngConfig = SetConfigDescription(orgConfig, "Test Description");
                jenkins.SetJobConfigAsync("FreeStyleConfig", cngConfig).Wait();
                updConfig = jenkins.GetJobConfigAsync("FreeStyleConfig").Result;
                descCng   = GetConfigDescription(updConfig);

                jenkins.SetJobConfigAsync("FreeStyleConfig", orgConfig).Wait();
            }

            // Assert
            Assert.IsNotNull(orgConfig);
            Assert.IsNotNull(updConfig);
            Assert.IsNotNull(cngConfig);
            Assert.AreEqual("Default Description", descOrg, nameof(descOrg));
            Assert.AreEqual("Test Description", descCng, nameof(descCng));
        }
        public void JobCreateDeleteTextTest()
        {
            // Arrange
            string config;
            JenkinsModelFreeStyleProject freeStyleJob = null;
            bool exists;

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                config = jenkins.GetJobConfigAsync("Freestyle").Result;
                jenkins.CreateJobAsync("Dummy", config).Wait();
                freeStyleJob = jenkins.GetJobAsync <JenkinsModelFreeStyleProject>("Dummy").Result;
                jenkins.DeleteJobAsync("Dummy").Wait();
                exists = jenkins.JobExists("Dummy").Result;
            }

            // Assert
            Assert.IsNotNull(freeStyleJob, nameof(freeStyleJob));
            Assert.IsFalse(exists, nameof(exists));
        }