Search in sources :

Example 1 with DeployPublisher

use of org.jenkinsci.test.acceptance.plugins.deploy.DeployPublisher 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)

Aggregations

CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Tomcat7Container (org.jenkinsci.test.acceptance.docker.fixtures.Tomcat7Container)1 DeployPublisher (org.jenkinsci.test.acceptance.plugins.deploy.DeployPublisher)1 Build (org.jenkinsci.test.acceptance.po.Build)1 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)1 JenkinsConfig (org.jenkinsci.test.acceptance.po.JenkinsConfig)1 ShellBuildStep (org.jenkinsci.test.acceptance.po.ShellBuildStep)1 CommandBuilder (org.jenkinsci.utils.process.CommandBuilder)1 Test (org.junit.Test)1