Search in sources :

Example 1 with CommandBuilder

use of org.jenkinsci.utils.process.CommandBuilder in project acceptance-test-harness by jenkinsci.

the class SAMLPluginTest method startSimpleSAML.

private SAMLContainer startSimpleSAML(String rootUrl) throws IOException, InterruptedException {
    Starter<SAMLContainer> starter = samlContainer.starter();
    File users = new File("src/test/resources/saml_plugin/users.php");
    File config = new File("src/test/resources/saml_plugin/config.php");
    File idp_metadata = new File("src/test/resources/saml_plugin/saml20-idp-hosted.php");
    starter.withOptions(new CommandBuilder(// service provider ID
    "-e", // service provider ID
    "SIMPLESAMLPHP_SP_ENTITY_ID=" + SERVICE_PROVIDER_ID, // login back URL
    "-e", // login back URL
    "SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE=" + rootUrl + "securityRealm/finishLogin", // unused
    "-e", // unused
    "SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE=" + rootUrl + "logout", // users info
    "-v", // users info
    users.getAbsolutePath() + ":/var/www/simplesamlphp/config/authsources.php", // config info,
    "-v", // config info,
    config.getAbsolutePath() + ":/var/www/simplesamlphp/config/config.php", // IdP advanced configuration
    "-v", // IdP advanced configuration
    idp_metadata.getAbsolutePath() + ":/var/www/simplesamlphp/metadata/saml20-idp-hosted.php"));
    SAMLContainer samlServer = starter.start();
    System.out.println("============ SAML Server: " + samlServer.host() + ":" + samlServer.port());
    return samlServer;
}
Also used : SAMLContainer(org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer) CommandBuilder(org.jenkinsci.utils.process.CommandBuilder) File(java.io.File)

Example 2 with CommandBuilder

use of org.jenkinsci.utils.process.CommandBuilder in project acceptance-test-harness by jenkinsci.

the class TSRWinstoneDockerController method startProcess.

@Override
public ProcessInputStream startProcess() throws IOException {
    try {
        // can't mount symlink very well, so we need to resolve it
        File war = this.war.getCanonicalFile();
        CommandBuilder opts = new CommandBuilder();
        opts.add("-v", getJenkinsHome() + ":/work");
        opts.add("-v", war.getParent() + ":/war");
        // TODO: unify ID and fixture
        DockerImage img;
        if (dockerImage != null)
            img = new DockerImage(dockerImage);
        else
            img = docker.build(fixtureType);
        container = img.start(fixtureType, opts, null);
        CommandBuilder cmds = new CommandBuilder();
        cmds.add("java");
        cmds.add("-DJENKINS_HOME=/work");
        cmds.add("-jar", "/war/" + war.getName());
        cmds.add("--ajp13Port=-1", "--controlPort=8081", "--httpPort=8080");
        return container.popen(cmds);
    } catch (InterruptedException e) {
        throw (IOException) new InterruptedIOException("Failed to launch winstone").initCause(e);
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) DockerImage(org.jenkinsci.test.acceptance.docker.DockerImage) CommandBuilder(org.jenkinsci.utils.process.CommandBuilder) File(java.io.File)

Example 3 with CommandBuilder

use of org.jenkinsci.utils.process.CommandBuilder in project acceptance-test-harness by jenkinsci.

the class JBossController method startProcess.

@Override
public ProcessInputStream startProcess() throws IOException {
    File jenkinsDeploymentDir = new File(jbossHome, "standalone/deployments/jenkins.war.deployed");
    if (jenkinsDeploymentDir.exists()) {
        FileUtils.forceDelete(jenkinsDeploymentDir);
    }
    File jenkinsDeploymentFailDir = new File(jbossHome, "standalone/deployments/jenkins.war.failed");
    if (jenkinsDeploymentFailDir.exists()) {
        FileUtils.forceDelete(jenkinsDeploymentFailDir);
    }
    File jenkinsWarDeploymentPath = new File(jbossHome, "standalone/deployments/jenkins.war");
    if (jenkinsWarDeploymentPath.exists()) {
        FileUtils.forceDelete(jenkinsWarDeploymentPath);
    }
    FileUtils.copyFile(war, jenkinsWarDeploymentPath);
    File jbossLog = new File(jbossHome, "/standalone/log/server.log");
    if (jbossLog.exists()) {
        FileUtils.forceDelete(jbossLog);
    }
    CommandBuilder cb = new CommandBuilder(jbossHome + "/bin/standalone.sh");
    cb.env.putAll(commonLaunchEnv());
    return cb.popen();
}
Also used : CommandBuilder(org.jenkinsci.utils.process.CommandBuilder) File(java.io.File)

Example 4 with CommandBuilder

use of org.jenkinsci.utils.process.CommandBuilder in project acceptance-test-harness by jenkinsci.

the class JBossController method stopNow.

@Override
public void stopNow() throws IOException {
    System.out.println("    Stopping a temporary Jenkins/JBoss instance\n");
    CommandBuilder cb = new CommandBuilder(jbossHome + "/bin/jboss-cli.sh", " --connect", "--command=:shutdown");
    try {
        int status = cb.system();
        if (status != 0) {
            System.out.println("Cannot stop JBoss: " + cb.toString());
        }
    } catch (InterruptedException e) {
        throw new IOException(e);
    }
}
Also used : IOException(java.io.IOException) CommandBuilder(org.jenkinsci.utils.process.CommandBuilder)

Example 5 with CommandBuilder

use of org.jenkinsci.utils.process.CommandBuilder in project acceptance-test-harness by jenkinsci.

the class TomcatController method startProcess.

@Override
public ProcessInputStream startProcess() throws IOException {
    try {
        File jenkinsDeploymentDir = new File(catalinaHome, "webapps/jenkins");
        if (jenkinsDeploymentDir.exists()) {
            FileUtils.forceDelete(jenkinsDeploymentDir);
        }
        File jenkinsWarDeploymentPath = new File(catalinaHome, "webapps/jenkins.war");
        if (jenkinsWarDeploymentPath.exists()) {
            FileUtils.forceDelete(jenkinsWarDeploymentPath);
        }
        FileUtils.copyFile(war, jenkinsWarDeploymentPath);
        File tomcatLog = new File(catalinaHome, "logs/catalina.out");
        if (tomcatLog.exists()) {
            FileUtils.forceDelete(tomcatLog);
        }
        CommandBuilder cb = new CommandBuilder(catalinaHome + "/bin/startup.sh");
        cb.env.putAll(commonLaunchEnv());
        int status = cb.system();
        if (status != 0) {
            throw new RuntimeException("Failed during Tomcat startup: " + cb.toString());
        }
        CommandBuilder tail = new CommandBuilder("tail").add("-f", tomcatLog);
        return tail.popen();
    } catch (InterruptedException e) {
        throw new IOException(e);
    }
}
Also used : IOException(java.io.IOException) CommandBuilder(org.jenkinsci.utils.process.CommandBuilder) File(java.io.File)

Aggregations

CommandBuilder (org.jenkinsci.utils.process.CommandBuilder)14 File (java.io.File)9 IOException (java.io.IOException)6 InterruptedIOException (java.io.InterruptedIOException)3 DockerImage (org.jenkinsci.test.acceptance.docker.DockerImage)2 Test (org.junit.Test)2 MalformedURLException (java.net.MalformedURLException)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 DockerAgentContainer (org.jenkinsci.test.acceptance.docker.fixtures.DockerAgentContainer)1 GitContainer (org.jenkinsci.test.acceptance.docker.fixtures.GitContainer)1 SAMLContainer (org.jenkinsci.test.acceptance.docker.fixtures.SAMLContainer)1 Tomcat7Container (org.jenkinsci.test.acceptance.docker.fixtures.Tomcat7Container)1 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)1 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)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 DeployPublisher (org.jenkinsci.test.acceptance.plugins.deploy.DeployPublisher)1 GitRepo (org.jenkinsci.test.acceptance.plugins.git.GitRepo)1