Search in sources :

Example 6 with ShellBuildStep

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

the class FreestyleJobTest method doNotDiscardSuccessfulBuilds.

@Test
@Category(SmokeTest.class)
public void doNotDiscardSuccessfulBuilds() {
    FreeStyleJob j = jenkins.jobs.create(FreeStyleJob.class);
    j.configure();
    try {
        check("Discard old builds");
    } catch (NoSuchElementException x) {
        // 1.636-
        check("Discard Old Builds");
    }
    j.control(by.name("_.numToKeepStr")).set(1);
    ShellBuildStep shellBuildStep = j.addShellStep("exit 0");
    j.save();
    Build b1 = j.scheduleBuild().waitUntilFinished();
    j.configure();
    shellBuildStep.command("exit 1");
    j.save();
    Build b2 = j.scheduleBuild().waitUntilFinished();
    Build b3 = j.scheduleBuild().waitUntilFinished();
    assertThat(b1, pageObjectExists());
    assertThat(b2, pageObjectDoesNotExist());
    assertThat(b3, pageObjectExists());
}
Also used : Build(org.jenkinsci.test.acceptance.po.Build) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) NoSuchElementException(org.openqa.selenium.NoSuchElementException) Category(org.junit.experimental.categories.Category) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) SmokeTest(org.jenkinsci.test.acceptance.junit.SmokeTest) Test(org.junit.Test)

Example 7 with ShellBuildStep

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

the class DeployPluginTest method deploy_sample_webapp_to_tomcat7.

@Test
@Native("bash")
@WithCredentials(credentialType = WithCredentials.USERNAME_PASSWORD, values = { "admin", "tomcat" }, id = "tomcat")
public void deploy_sample_webapp_to_tomcat7() throws IOException, InterruptedException {
    if (SystemUtils.IS_OS_WINDOWS) {
        // TODO move somewhere else...
        String path = new CommandBuilder("where.exe", "bash.exe").popen().asText().trim();
        // where will return all matches and we only want the first.
        path = path.replaceAll("\r\n.*", "");
        JenkinsConfig conf = jenkins.getConfigPage();
        JenkinsConfig cp = jenkins.getConfigPage();
        cp.configure();
        cp.setShell(path);
        cp.save();
    }
    Tomcat7Container f = docker.get();
    FreeStyleJob j = jenkins.jobs.create();
    j.configure();
    ShellBuildStep s;
    {
        s = j.addShellStep(resource("/deploy_plugin/build-war.sh"));
        DeployPublisher d = j.addPublisher(DeployPublisher.class);
        d.war.set("my-webapp/target/*.war");
        d.contextPath.set("test");
        d.useContainer("Tomcat 7.x Remote", "Tomcat 7.x");
        d.setCredentials("tomcat");
        d.url.set(f.getUrl().toExternalForm());
    }
    j.save();
    Build b = j.startBuild().shouldSucceed();
    b.shouldContainsConsoleOutput("to container Tomcat 7.x Remote");
    assertThat(readText(f), containsString("Hello World!"));
    j.configure();
    s.command("cd my-webapp && echo '<html><body>Hello Jenkins</body></html>' > src/main/webapp/index.jsp && mvn install");
    j.save();
    b = j.startBuild().shouldSucceed();
    b.shouldContainsConsoleOutput("Redeploying");
    assertThat(readText(f), containsString("Hello Jenkins"));
}
Also used : DeployPublisher(org.jenkinsci.test.acceptance.plugins.deploy.DeployPublisher) Build(org.jenkinsci.test.acceptance.po.Build) JenkinsConfig(org.jenkinsci.test.acceptance.po.JenkinsConfig) ShellBuildStep(org.jenkinsci.test.acceptance.po.ShellBuildStep) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) Tomcat7Container(org.jenkinsci.test.acceptance.docker.fixtures.Tomcat7Container) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) CommandBuilder(org.jenkinsci.utils.process.CommandBuilder) Test(org.junit.Test)

Example 8 with ShellBuildStep

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

the class WarningsPluginTest method createAndBuildCompileJobOnAgent.

private WarningsAction createAndBuildCompileJobOnAgent(Resource resource, String command) {
    DumbSlave dockerSlave = createDockerAgent();
    FreeStyleJob job = prepareDockerSlave(dockerSlave);
    job.configure();
    job.copyResource(resource);
    ShellBuildStep shellBuildStep = job.addBuildStep(ShellBuildStep.class);
    shellBuildStep.command(command);
    WarningsPublisher warningsPublisher = job.addPublisher(WarningsPublisher.class);
    warningsPublisher.addConsoleScanner(JAVA_ID);
    job.save();
    Build build = buildSuccessfulJob(job);
    assertThatActionExists(job, build, "Java Warnings");
    WarningsAction action = createJavaResultAction(build);
    action.open();
    return action;
}
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) DumbSlave(org.jenkinsci.test.acceptance.po.DumbSlave)

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