public void JobRunFileTest()
        {
            // Arrange
            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream);

            writer.WriteLine("This is a test file!");
            stream.Position = 0;

            JenkinsRunProgress     progress;
            JenkinsBuildParameters par = new JenkinsBuildParameters();

            par.Add("ParamA", "");
            par.Add("ParamB", "");
            par.Add("ParamC", "");
            par.Add("CheckD", true);
            par.Add("CheckE", false);
            par.Add("TextBoxF", "Dies ist ein\r\nkleines Beispiel");
            par.Add("TestFile", stream, "FileName.bin");

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                progress = jenkins.RunJobAsync("FreestyleFile", par).Result;
            }

            // Assert
            Assert.IsNotNull(progress, nameof(progress));
            //Assert.IsNotNull(item.Url, "build.Result");
        }
예제 #2
0
        public void RunTest()
        {
            //JenkinsRun build;

            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                /*build =*/ var x = jenkins.RunJobAsync("Freestyle Test Pure").Result;
            }

            //Assert.AreEqual(JenkinsResult.Success, build.Result, "build.Result");
        }
        //[TestMethod]
        public void JobRunPeningTest()
        {
            // Arrange
            JenkinsRunProgress longRun;
            JenkinsRunProgress progress;

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                longRun = jenkins.RunJobAsync("FreestyleRun1h", null, new JenkinsRunConfig()
                {
                    RunMode = JenkinsRunMode.Started
                }, null, CancellationToken.None).Result;

                progress = jenkins.RunJobAsync("Freestyle").Result;

                jenkins.StopJobAsync(longRun.JobName, longRun.BuildNum).Wait();
            }

            // Assert
            Assert.IsNotNull(progress, nameof(progress));
            Assert.AreEqual(JenkinsRunStatus.Stuck, progress.Status, nameof(progress.Status));
        }
        public void JobRunDisabledTest()
        {
            // Arrange
            JenkinsRunProgress progress;

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                progress = jenkins.RunJobAsync("FreestyleDisabled").Result;
            }

            // Assert
            Assert.IsNotNull(progress, nameof(progress));
            Assert.AreEqual(JenkinsRunStatus.Disabled, progress.Status, nameof(progress.Status));
        }
        public void JobRunOfflineTest()
        {
            // Arrange
            JenkinsRunProgress progress;

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                jenkins.RunProgress += OnRunProgress;
                progress             = jenkins.RunJobAsync("FreestyleOffline").Result;
            }

            // Assert
            Assert.IsNotNull(progress, nameof(progress));
            Assert.AreEqual(JenkinsRunStatus.Stuck, progress.Status, nameof(progress.Status));
        }
        public void JobRunSimpleFinishedTest()
        {
            // Arrange
            JenkinsRunProgress progress;

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                jenkins.RunConfig.RunMode = JenkinsRunMode.Finished;
                progress = jenkins.RunJobAsync("FreeStyle").Result;
            }

            // Assert
            Assert.IsNotNull(progress, nameof(progress));
            Assert.AreEqual(JenkinsRunStatus.Finished, progress.Status, nameof(progress.Status));
        }
        public void JobRunParamTest()
        {
            // Arrange
            JenkinsRunProgress     progress;
            JenkinsBuildParameters par = new JenkinsBuildParameters();

            par.Add("ParamA", "TestA");
            par.Add("ParamB", "TestB");
            par.Add("ParamC", "TestC");
            par.Add("CheckD", true);
            par.Add("CheckE", false);
            par.Add("TextBoxF", "TextF1\r\nTextF2\r\nTextF3");

            // Act
            using (Jenkins jenkins = new Jenkins(host, this.login, this.password))
            {
                progress = jenkins.RunJobAsync("FreestyleParam", par).Result;
            }

            // Assert
            Assert.IsNotNull(progress, nameof(progress));
            //Assert.IsNotNull(item.Url, "build.Result");
        }