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"));
}
Aggregations