コード例 #1
0
        public void BuildTest()
        {
            JenkinsModelFreeStyleBuild freeStyleBuild = null;
            //JenkinsBuildExternal externalBuild = null;
            JenkinsMatrixMatrixBuild matrixBuild = null;
            JenkinsOrgJenkinsciPluginsWorkflowJobWorkflowRun workflowBuild = null;

            //JenkinsBuildWorkflowMultiBranch multiBranchBuild = null;
            //JenkinsBuildFolder folderBuild = null;
            //JenkinsBuildOrganizationFolder organizationFolderBuild = null;

            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                freeStyleBuild = jenkins.GetLastBuildAsync("Freestyle Test Pure").Result as JenkinsModelFreeStyleBuild;
                //externalBuild = jenkins.GetBuildAsync("External Job", 1).Result as JenkinsBuildExternal;
                matrixBuild   = jenkins.GetBuildAsync("Multiconfiguration", 1).Result as JenkinsMatrixMatrixBuild;
                workflowBuild = jenkins.GetBuildAsync("Pipeline", 1).Result as JenkinsOrgJenkinsciPluginsWorkflowJobWorkflowRun;
                //multiBranchBuild = jenkins.GetBuildAsync("Multibranch", 1).Result as JenkinsBuildWorkflowMultiBranch;
                //folderBuild = jenkins.GetBuildAsync("Folder", 1).Result as JenkinsBuildFolder;
                //organizationFolderBuild = jenkins.GetBuildAsync("GitHub", 1).Result as JenkinsBuildOrganizationFolder;
            }

            Assert.IsNotNull(freeStyleBuild);
            //Assert.IsNotNull(externalBuild);
            Assert.IsNotNull(matrixBuild);
            //Assert.IsNotNull(workflowBuild);
            //Assert.IsNotNull(multiBranchBuild);
            //Assert.IsNotNull(folderBuild);
            //Assert.IsNotNull(organizationFolderBuild);
        }
コード例 #2
0
        public void BuildGetGenericTest()
        {
            // Arrange
            JenkinsModelFreeStyleBuild freeStyleBuild = null;
            //JenkinsBuildExternal externalBuild = null;
            JenkinsMatrixMatrixBuild    matrixBuild   = null;
            JenkinsJenkinsciWorkflowRun workflowBuild = null;

            //JenkinsBuildWorkflowMultiBranch multiBranchBuild = null;
            //JenkinsBuildFolder folderBuild = null;
            //JenkinsBuildOrganizationFolder organizationFolderBuild = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                freeStyleBuild = jenkins.GetLastBuildAsync <JenkinsModelFreeStyleBuild>("Freestyle").Result;
                //externalBuild = jenkins.GetBuildAsync("ExternalJob", 1).Result as JenkinsBuildExternal;
                matrixBuild   = jenkins.GetBuildAsync <JenkinsMatrixMatrixBuild>("Multiconfiguration", 1).Result;
                workflowBuild = jenkins.GetBuildAsync <JenkinsJenkinsciWorkflowRun>("Pipeline", 1).Result;
                //multiBranchBuild = jenkins.GetBuildAsync("MultibranchPipeline", 1).Result as JenkinsBuildWorkflowMultiBranch;
                //folderBuild = jenkins.GetBuildAsync("Folder", 1).Result as JenkinsBuildFolder;
                //organizationFolderBuild = jenkins.GetBuildAsync("GitHubOrganization", 1).Result as JenkinsBuildOrganizationFolder;
            }

            // Assert
            Assert.IsNotNull(freeStyleBuild);
            //Assert.IsNotNull(externalBuild);
            Assert.IsNotNull(matrixBuild);
            Assert.IsNotNull(workflowBuild);
            //Assert.IsNotNull(multiBranchBuild);
            //Assert.IsNotNull(folderBuild);
            //Assert.IsNotNull(organizationFolderBuild);
        }
コード例 #3
0
        public void BuildGraphTest()
        {
            // Arrange
            JenkinsModelFreeStyleBuild freeStyleBuild = null;
            JenkinsJenkinsciBuildGraph buildGraph     = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                freeStyleBuild = jenkins.GetLastBuildAsync <JenkinsModelFreeStyleBuild>("FreestyleTree").Result;

                buildGraph = jenkins.GetBuildGraph("FreestyleTree", freeStyleBuild.Number).Result;
            }

            // Assert
            Assert.IsNotNull(buildGraph, nameof(buildGraph));
            Assert.IsNotNull(buildGraph.BuildGraph, nameof(buildGraph.BuildGraph));
        }
コード例 #4
0
        public void BuildConsoleOutputTest()
        {
            // Arrange
            JenkinsModelFreeStyleBuild freeStyleBuild = null;
            string consoleOutput = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                freeStyleBuild = jenkins.GetLastBuildAsync <JenkinsModelFreeStyleBuild>("FreeStyle").Result;

                consoleOutput = jenkins.GetBuildConsoleOutputAsync("FreeStyle", freeStyleBuild.Number, 0).Result;
            }

            // Assert
            Assert.IsNotNull(consoleOutput, nameof(consoleOutput));
            StringAssert.StartsWith(consoleOutput, "Started by user Tester");
        }
コード例 #5
0
        public void BuildSetInformationTest()
        {
            // Arrange
            JenkinsModelFreeStyleBuild freeStyleBuild = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                freeStyleBuild = jenkins.GetLastBuildAsync <JenkinsModelFreeStyleBuild>("FreeStyle").Result;
                jenkins.SetBuildInformation("FreeStyle", freeStyleBuild.Number, "Build name", "Build description").Wait();
                freeStyleBuild = jenkins.GetBuildAsync <JenkinsModelFreeStyleBuild>("FreeStyle", freeStyleBuild.Number).Result;
                jenkins.SetBuildInformation("FreeStyle", freeStyleBuild.Number, "", "").Wait();
            }

            // Assert
            Assert.IsNotNull(freeStyleBuild, nameof(freeStyleBuild));

            Assert.AreEqual("Build name", freeStyleBuild.DisplayName, nameof(freeStyleBuild.DisplayName));
            Assert.AreEqual("Build description", freeStyleBuild.Description, nameof(freeStyleBuild.Description));
        }
コード例 #6
0
        public void BuildEnvInjectVarListTest()
        {
            // Arrange
            JenkinsModelFreeStyleBuild       freeStyleBuild = null;
            JenkinsJenkinsciEnvInjectVarList varList        = null;

            // Act
            using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password))
            {
                freeStyleBuild = jenkins.GetLastBuildAsync <JenkinsModelFreeStyleBuild>("FreeStyle").Result;

                varList = jenkins.GetEnvInjectVarListAsync("FreeStyle", freeStyleBuild.Number).Result;
            }

            // Assert
            Assert.IsNotNull(varList, nameof(varList));
            var dict = varList.EnvMapDict;

            Assert.AreEqual("FreeStyle", dict["JOB_NAME"]);
            Assert.AreEqual(@"C:\Users\Public", dict["PUBLIC"]);
        }