use of hudson.cli.CLICommandInvoker in project workflow-job-plugin by jenkinsci.
the class CLITest method reload.
@Issue("JENKINS-30785")
@Test
public void reload() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo 'first version'", true));
r.assertLogContains("first version", r.buildAndAssertSuccess(p));
File configXml = new File(p.getRootDir(), "config.xml");
FileUtils.write(configXml, FileUtils.readFileToString(configXml).replace("first version", "second version"));
assertThat(new CLICommandInvoker(r, "reload-job").invokeWithArgs("p"), CLICommandInvoker.Matcher.succeededSilently());
r.assertLogContains("second version", r.buildAndAssertSuccess(p));
CLICommandInvoker.Result res = new CLICommandInvoker(r, "reload-job").invokeWithArgs("q");
assertThat(res, CLICommandInvoker.Matcher.failedWith(3));
assertThat(res.stderr(), containsString("No such item āqā exists. Perhaps you meant āpā?"));
}
use of hudson.cli.CLICommandInvoker in project workflow-job-plugin by jenkinsci.
the class CLITest method setBuildDescriptionAndDisplayName.
@Test
public void setBuildDescriptionAndDisplayName() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("", true));
WorkflowRun b = r.buildAndAssertSuccess(p);
assertThat(new CLICommandInvoker(r, "set-build-description").invokeWithArgs("p", "1", "the desc"), CLICommandInvoker.Matcher.succeededSilently());
assertEquals("the desc", b.getDescription());
assertThat(new CLICommandInvoker(r, "set-build-display-name").invokeWithArgs("p", "1", "the name"), CLICommandInvoker.Matcher.succeededSilently());
assertEquals("the name", b.getDisplayName());
}
use of hudson.cli.CLICommandInvoker in project workflow-job-plugin by jenkinsci.
the class CLITest method listChanges.
@Test
public void listChanges() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("node {def s = new org.jvnet.hudson.test.FakeChangeLogSCM(); s.addChange().withAuthor('alice').withMsg('hello'); checkout s}", false));
r.buildAndAssertSuccess(p);
CLICommandInvoker.Result res = new CLICommandInvoker(r, "list-changes").invokeWithArgs("p", "1");
assertThat(res, CLICommandInvoker.Matcher.succeeded());
assertThat(res.stdout(), containsString("alice\thello"));
}
use of hudson.cli.CLICommandInvoker in project workflow-job-plugin by jenkinsci.
the class WorkflowJobTest method disabled.
@Issue("JENKINS-27299")
@Test
public void disabled() throws Exception {
WorkflowJob p = j.jenkins.createProject(WorkflowJob.class, "p");
assertFalse(p.isDisabled());
assertTrue(p.isBuildable());
JenkinsRule.WebClient wc = j.createWebClient();
j.submit(wc.getPage(p).<HtmlForm>getHtmlElementById("disable-project"));
assertTrue(p.isDisabled());
assertFalse(p.isBuildable());
HtmlForm form = wc.getPage(p, "configure").getFormByName("config");
HtmlCheckBoxInput checkbox = form.getInputByName("disable");
assertTrue(checkbox.isChecked());
checkbox.setChecked(false);
j.submit(form);
assertFalse(p.isDisabled());
wc.getPage(new WebRequest(wc.createCrumbedUrl(p.getUrl() + "disable"), HttpMethod.POST));
assertTrue(p.isDisabled());
assertNull(p.scheduleBuild2(0));
assertThat(new CLICommandInvoker(j, "enable-job").invokeWithArgs("p"), CLICommandInvoker.Matcher.succeededSilently());
assertFalse(p.isDisabled());
}
use of hudson.cli.CLICommandInvoker in project workflow-job-plugin by jenkinsci.
the class CLITest method deleteBuilds.
@Test
public void deleteBuilds() throws Exception {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("", true));
for (int i = 0; i < 5; i++) {
r.buildAndAssertSuccess(p);
}
assertThat(new CLICommandInvoker(r, "delete-builds").invokeWithArgs("p", "2-4"), CLICommandInvoker.Matcher.succeeded());
assertEquals("[5, 1]", p.getBuildsAsMap().keySet().toString());
}
Aggregations