Search in sources :

Example 1 with ShellBuildStep

use of org.jenkinsci.test.acceptance.po.ShellBuildStep in project acceptance-test-harness by jenkinsci.

the class WarningsPluginTest method should_scan_console_log_of_slave_build.

@Test
@WithDocker
@WithCredentials(credentialType = WithCredentials.SSH_USERNAME_PRIVATE_KEY, values = { CREDENTIALS_ID, CREDENTIALS_KEY })
@WithPlugins("ssh-slaves")
public void should_scan_console_log_of_slave_build() throws ExecutionException, InterruptedException {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource(RESOURCE_WARNING_MAIN_JAVA_PATH));
    ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
    shellBuildStep.command(CMD_WARNING_MAIN_JAVA_CONSOLE);
    WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
    warningsPublisher.addConsoleScanner(JAVA_ID);
    job.save();
    Build build = job.startBuild().shouldSucceed();
    assertThatActionExists(job, build, "Java Warnings");
    WarningsAction action = createJavaResultAction(build);
    assertThatWarningsCountInSummaryIs(action, 3);
    String codeLine = action.getLinkedSourceFileText(AnalysisAction.Tab.DETAILS, "WarningMain.java", 10);
    String[] codeLineArr = codeLine.trim().split("\\s+", 2);
    assertThat("Warning should be at line", codeLineArr[0], is("10"));
    assertThat("Assert failed comparing code line is", codeLineArr[1], is("text =  (TextClass) text2;"));
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) WarningsPublisher(org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) WarningsAction(org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave) WithCredentials(org.jenkinsci.test.acceptance.junit.WithCredentials) Test(org.junit.Test) WithPlugins(org.jenkinsci.test.acceptance.junit.WithPlugins) WithDocker(org.jenkinsci.test.acceptance.junit.WithDocker)

Example 2 with ShellBuildStep

use of org.jenkinsci.test.acceptance.po.ShellBuildStep in project acceptance-test-harness by jenkinsci.

the class MavenModuleSet method addShellStep.

@Override
public ShellBuildStep addShellStep(String shell) {
    ShellBuildStep step = addPreBuildStep(ShellBuildStep.class);
    step.command(shell);
    return step;
}
Also used : ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep)

Example 3 with ShellBuildStep

use of org.jenkinsci.test.acceptance.po.ShellBuildStep in project acceptance-test-harness by jenkinsci.

the class CredentialsBindingTest method testTextBinding.

@Test
public void testTextBinding() {
    CredentialsPage mc = new CredentialsPage(jenkins, ManagedCredentials.DEFAULT_DOMAIN);
    mc.open();
    StringCredentials cred = mc.add(StringCredentials.class);
    cred.scope.select("GLOBAL");
    cred.secret.set(SECRET_TEXT);
    mc.create();
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    job.check("Use secret text(s) or file(s)");
    ManagedCredentialsBinding mcb = new ManagedCredentialsBinding(job);
    SecretStringCredentialsBinding cb = mcb.addCredentialBinding(SecretStringCredentialsBinding.class);
    cb.variable.set("BINDED_SECRET");
    ShellBuildStep shell = job.addBuildStep(ShellBuildStep.class);
    shell.command("if [ \"$BINDED_SECRET\" = \"" + SECRET_TEXT + "\" ] \n then \n echo \"" + SECRET_OUTPUT + "\" \n fi");
    job.save();
    Build b = job.scheduleBuild();
    b.shouldSucceed();
    assertThat(b.getConsole(), containsString(SECRET_OUTPUT));
}
Also used : SecretStringCredentialsBinding(org.jenkinsci.test.acceptance.plugins.credentialsbinding.SecretStringCredentialsBinding) ManagedCredentialsBinding(org.jenkinsci.test.acceptance.plugins.credentialsbinding.ManagedCredentialsBinding) CredentialsPage(org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage) Build(org.jenkinsci.test.acceptance.po.Build) StringCredentials(org.jenkinsci.test.acceptance.plugins.credentials.StringCredentials) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 4 with ShellBuildStep

use of org.jenkinsci.test.acceptance.po.ShellBuildStep in project acceptance-test-harness by jenkinsci.

the class JobConfigHistoryPluginTest method show_difference_in_config_history.

@Test
public void show_difference_in_config_history() {
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    ShellBuildStep step = job.addShellStep(LS_COMMAND);
    job.save();
    job.configure();
    step.command(LS_LH_COMMAND);
    job.save();
    JobConfigHistory action = job.action(JobConfigHistory.class);
    action.open();
    assertThat(driver, Matchers.hasContent(CREATED));
    assertThat(driver, Matchers.hasContent("Changed"));
    action.showLastChange();
    assertThat(driver, Matchers.hasElement(by.xpath("//td[@class='diff_original' and contains(string(.), '" + String.format(COMMAND_NODE, LS_COMMAND) + "')]")));
    assertThat(driver, Matchers.hasElement(by.xpath("//td[@class='diff_revised' and contains(string(.), '" + String.format(COMMAND_NODE, LS_LH_COMMAND) + "')]")));
}
Also used : JobConfigHistory(org.jenkinsci.test.acceptance.plugins.job_config_history.JobConfigHistory) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 5 with ShellBuildStep

use of org.jenkinsci.test.acceptance.po.ShellBuildStep in project acceptance-test-harness by jenkinsci.

the class FreestyleJobTest method apply_then_save.

@Test
@Issue("JENKINS-38928")
public void apply_then_save() {
    FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class, "simple-job");
    assertThat(j, pageObjectExists());
    j.configure();
    ShellBuildStep shell = j.addBuildStep(ShellBuildStep.class);
    shell.command("echo 1");
    j.apply();
    j.save();
    String src = getConfigXml(j);
    assertThat(src, containsString("echo 1"));
}
Also used : ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Matchers.containsString(org.jenkinsci.test.acceptance.Matchers.containsString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) SmokeTest(org.jenkinsci.test.acceptance.junit.SmokeTest) Test(org.junit.Test)

Aggregations

ShellBuildStep (org.jenkinsci.test.acceptance.po.ShellBuildStep)8 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)7 Test (org.junit.Test)6 Build (org.jenkinsci.test.acceptance.po.Build)5 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 SmokeTest (org.jenkinsci.test.acceptance.junit.SmokeTest)2 WarningsAction (org.jenkinsci.test.acceptance.plugins.warnings.WarningsAction)2 WarningsPublisher (org.jenkinsci.test.acceptance.plugins.warnings.WarningsPublisher)2 DumbSlave (org.jenkinsci.test.acceptance.po.DumbSlave)2 Matchers.containsString (org.jenkinsci.test.acceptance.Matchers.containsString)1 Tomcat7Container (org.jenkinsci.test.acceptance.docker.fixtures.Tomcat7Container)1 WithCredentials (org.jenkinsci.test.acceptance.junit.WithCredentials)1 WithDocker (org.jenkinsci.test.acceptance.junit.WithDocker)1 WithPlugins (org.jenkinsci.test.acceptance.junit.WithPlugins)1 CredentialsPage (org.jenkinsci.test.acceptance.plugins.credentials.CredentialsPage)1 StringCredentials (org.jenkinsci.test.acceptance.plugins.credentials.StringCredentials)1 ManagedCredentialsBinding (org.jenkinsci.test.acceptance.plugins.credentialsbinding.ManagedCredentialsBinding)1 SecretStringCredentialsBinding (org.jenkinsci.test.acceptance.plugins.credentialsbinding.SecretStringCredentialsBinding)1 DeployPublisher (org.jenkinsci.test.acceptance.plugins.deploy.DeployPublisher)1