public void JobGetGenericTest() { // Arrange JenkinsModelFreeStyleProject freeStyleJob = null; JenkinsModelExternalJob externalJob = null; JenkinsMatrixMatrixProject matrixJob = null; JenkinsJenkinsciWorkflowJob workflowJob = null; //JenkinsJenkinsciWorkflowMultiBranchProject multiBranchJob = null; //JenkinsCloudbeesFolder folderJob = null; //JenkinsBranchOrganizationFolder organizationFolderJob = null; // Act using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password)) { freeStyleJob = jenkins.GetJobAsync <JenkinsModelFreeStyleProject>("FreeStyle").Result; externalJob = jenkins.GetJobAsync <JenkinsModelExternalJob>("ExternalJob").Result; matrixJob = jenkins.GetJobAsync <JenkinsMatrixMatrixProject>("Multiconfiguration").Result; workflowJob = jenkins.GetJobAsync <JenkinsJenkinsciWorkflowJob>("Pipeline").Result; //multiBranchJob = jenkins.GetJobAsync<JenkinsJenkinsciWorkflowMultiBranchProject>("MultibranchPipeline").Result; //folderJob = jenkins.GetJobAsync<JenkinsCloudbeesFolder>("Folder").Result; //organizationFolderJob = jenkins.GetJobAsync<JenkinsBranchOrganizationFolder>("GitHubOrganization").Result; } // Assert Assert.IsNotNull(freeStyleJob); Assert.IsNotNull(externalJob); Assert.IsNotNull(matrixJob); Assert.IsNotNull(workflowJob); //Assert.IsNotNull(multiBranchJob); //Assert.IsNotNull(folderJob); //Assert.IsNotNull(organizationFolderJob); }
public void JobGetTest() { // Arrange JenkinsModelFreeStyleProject freeStyleJob = null; JenkinsModelExternalJob externalJob = null; JenkinsMatrixMatrixProject matrixJob = null; JenkinsJenkinsciWorkflowJob workflowJob = null; //JenkinsJenkinsciWorkflowMultiBranchProject multiBranchJob = null; //JenkinsCloudbeesFolder folderJob = null; //JenkinsBranchOrganizationFolder organizationFolderJob = null; // Act using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password)) { freeStyleJob = jenkins.GetJobAsync("FreeStyle").Result as JenkinsModelFreeStyleProject; externalJob = jenkins.GetJobAsync("ExternalJob").Result as JenkinsModelExternalJob; matrixJob = jenkins.GetJobAsync("Multiconfiguration").Result as JenkinsMatrixMatrixProject; workflowJob = jenkins.GetJobAsync("Pipeline").Result as JenkinsJenkinsciWorkflowJob; //multiBranchJob = jenkins.GetJobAsync("MultibranchPipeline").Result as JenkinsJenkinsciWorkflowMultiBranchProject; //folderJob = jenkins.GetJobAsync("Folder").Result as JenkinsCloudbeesFolder; //organizationFolderJob = jenkins.GetJobAsync("GitHubOrganization").Result as JenkinsBranchOrganizationFolder; } // Assert Assert.IsNotNull(freeStyleJob); Assert.IsNotNull(externalJob); Assert.IsNotNull(matrixJob); Assert.IsNotNull(workflowJob); //Assert.IsNotNull(multiBranchJob); //Assert.IsNotNull(folderJob); //Assert.IsNotNull(organizationFolderJob); Assert.IsNotNull(freeStyleJob.Actions, nameof(freeStyleJob.Actions)); Assert.AreEqual("Project description", freeStyleJob.Description, nameof(freeStyleJob.Description)); Assert.AreEqual("FreeStyle", freeStyleJob.DisplayName, nameof(freeStyleJob.DisplayName)); Assert.AreEqual("FreeStyle", freeStyleJob.Name, nameof(freeStyleJob.Name)); Assert.AreEqual($"{this.host}job/FreeStyle/", freeStyleJob.Url, nameof(freeStyleJob.Url)); Assert.AreEqual(true, freeStyleJob.IsBuildable, nameof(freeStyleJob.IsBuildable)); Assert.IsNotNull(freeStyleJob.Builds, nameof(freeStyleJob.Builds)); //Assert.IsTrue(freeStyleJob.State.HasFlag(JenkinsJobState.Success), "color"); Assert.IsNotNull(freeStyleJob.FirstBuild, nameof(freeStyleJob.FirstBuild)); Assert.IsNotNull(freeStyleJob.HealthReports, nameof(freeStyleJob.HealthReports)); }
public void BuildDeleteTest() { // Arrange JenkinsModelFreeStyleProject freeStyleJob = null; int delBuildNum = 0; // Act using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password)) { freeStyleJob = jenkins.GetJobAsync <JenkinsModelFreeStyleProject>("FreeStyle").Result; delBuildNum = freeStyleJob.FirstBuild.Number; jenkins.DeleteBuildAsync("FreeStyle", delBuildNum).Wait(); freeStyleJob = jenkins.GetJobAsync <JenkinsModelFreeStyleProject>("FreeStyle").Result; } // Assert Assert.IsNotNull(freeStyleJob, nameof(freeStyleJob)); Assert.IsTrue(delBuildNum < freeStyleJob.FirstBuild.Number); }
public void JobGetFailedTest() { // Arrange JenkinsModelFreeStyleProject freeStyleJob = null; // Act using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password)) { freeStyleJob = jenkins.GetJobAsync("FreeStyleNotExists").Result as JenkinsModelFreeStyleProject; } // Assert }
public void JobDisableEnableTest() { // Arrange JenkinsModelFreeStyleProject freeStyleJobDisabled = null; JenkinsModelFreeStyleProject freeStyleJobEnabled = null; // Act using (Jenkins jenkins = new Jenkins(host, this.login, this.password)) { jenkins.DisableJobAsync("FreestyleDisableEnable", CancellationToken.None).Wait(); freeStyleJobDisabled = jenkins.GetJobAsync <JenkinsModelFreeStyleProject>("FreestyleDisableEnable").Result; jenkins.EnableJobAsync("FreestyleDisableEnable", CancellationToken.None).Wait(); freeStyleJobEnabled = jenkins.GetJobAsync <JenkinsModelFreeStyleProject>("FreestyleDisableEnable").Result; } // Assert Assert.IsNotNull(freeStyleJobDisabled, nameof(freeStyleJobDisabled)); Assert.IsTrue(freeStyleJobDisabled.IsDisabled, nameof(freeStyleJobDisabled.IsDisabled)); Assert.IsNotNull(freeStyleJobEnabled, nameof(freeStyleJobEnabled)); Assert.IsFalse(freeStyleJobEnabled.IsDisabled, nameof(freeStyleJobDisabled.IsDisabled)); }
public void JobTest() { string jobName = "Freestyle Test Parameter"; JenkinsModelFreeStyleProject freeStyleJob = null; JenkinsModelExternalJob externalJob = null; JenkinsMatrixMatrixProject matrixJob = null; JenkinsOrgJenkinsciPluginsWorkflowJobWorkflowJob workflowJob = null; JenkinsOrgJenkinsciPluginsWorkflowMultibranchWorkflowMultiBranchProject multiBranchJob = null; JenkinsComCloudbeesHudsonPluginsFolderFolder folderJob = null; JenkinsBranchOrganizationFolder organizationFolderJob = null; using (Jenkins jenkins = new Jenkins(this.host, this.login, this.password)) { freeStyleJob = jenkins.GetJobAsync("Freestyle Test Pure").Result as JenkinsModelFreeStyleProject; externalJob = jenkins.GetJobAsync("External Job").Result as JenkinsModelExternalJob; matrixJob = jenkins.GetJobAsync("Multiconfiguration").Result as JenkinsMatrixMatrixProject; workflowJob = jenkins.GetJobAsync("Pipeline").Result as JenkinsOrgJenkinsciPluginsWorkflowJobWorkflowJob; multiBranchJob = jenkins.GetJobAsync("Multibranch").Result as JenkinsOrgJenkinsciPluginsWorkflowMultibranchWorkflowMultiBranchProject; folderJob = jenkins.GetJobAsync("Folder").Result as JenkinsComCloudbeesHudsonPluginsFolderFolder; organizationFolderJob = jenkins.GetJobAsync("GitHub").Result as JenkinsBranchOrganizationFolder; } Assert.IsNotNull(freeStyleJob); Assert.IsNotNull(externalJob); Assert.IsNotNull(matrixJob); Assert.IsNotNull(workflowJob); Assert.IsNotNull(multiBranchJob); Assert.IsNotNull(folderJob); Assert.IsNotNull(organizationFolderJob); Assert.IsNotNull(freeStyleJob.Actions, "actions"); Assert.AreEqual("Test with Parameters", freeStyleJob.Description, "description"); Assert.AreEqual(jobName, freeStyleJob.DisplayName, "job.DisplayName"); Assert.AreEqual(jobName, freeStyleJob.Name, "job.Name"); Assert.AreEqual($"{this.host}/job/Freestyle%20Test%20Parameter/", freeStyleJob.Url, "job.Url"); Assert.AreEqual(true, freeStyleJob.IsBuildable, "job.IsBuildable"); Assert.IsNotNull(freeStyleJob.Builds, "builds"); //Assert.IsTrue(freeStyleJob.State.HasFlag(JenkinsJobState.Success), "color"); Assert.IsNotNull(freeStyleJob.FirstBuild, "firstBuild"); Assert.IsNotNull(freeStyleJob.HealthReports, "healthReport"); }
public void JobCreateDeleteXmlTest() { // Arrange XmlDocument config; JenkinsModelFreeStyleProject freeStyleJob = null; bool exists; // Act using (Jenkins jenkins = new Jenkins(host, this.login, this.password)) { config = jenkins.GetJobConfigXmlAsync("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)); }
internal JenkinsJob(Jenkins jenkins, string jobName) { this.jenkins = jenkins; this.modelJob = JenkinsRun.Run(() => jenkins.GetJobAsync <JenkinsModelJob>(jobName).Result); this.isCompleteLoaded = true; }
/// <summary> /// Refresh the properties of the Jenkins job. /// </summary> public void Update() { this.modelJob = JenkinsRun.Run(() => jenkins.GetJobAsync <JenkinsModelJob>(this.Name).Result); }