Search in sources :

Example 11 with Ssh

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

the class SimpleMachine method connect.

@Override
public Ssh connect() {
    Ssh ssh = null;
    try {
        ssh = new Ssh(getPublicIpAddress());
        machineProvider.authenticator().authenticate(ssh.getConnection());
        return ssh;
    } catch (IOException e) {
        if (ssh != null) {
            ssh.close();
        }
        throw new AssertionError("Failed to create ssh connection", e);
    }
}
Also used : Ssh(org.jenkinsci.test.acceptance.Ssh) IOException(java.io.IOException)

Example 12 with Ssh

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

the class JenkinsDownloader method materialize.

@Override
public void materialize(Machine machine, String path) {
    if (StringUtils.isBlank(jenkinsMd5Sum)) {
        try {
            URL url = new URL(jenkinsWarLocation + ".md5");
            String content = url.getContent().toString().trim();
            if (content.matches("[a-zA-Z0-9]{32}")) {
                jenkinsMd5Sum = content;
                logger.info("Remote MD5 sum of jenkins.war is {}", jenkinsMd5Sum);
            }
        } catch (IOException e) {
        // forget it!
        }
    }
    try (Ssh ssh = machine.connect()) {
        if (!remoteFileExists(ssh.getConnection(), path, jenkinsMd5Sum)) {
            ssh.executeRemoteCommand("mkdir -p " + Ssh.escape(FileUtils.dirname(path)));
            ssh.executeRemoteCommand(String.format("wget -q -O %s %s", Ssh.escape(path), Ssh.escape(jenkinsWarLocation)));
        }
    }
}
Also used : Ssh(org.jenkinsci.test.acceptance.Ssh) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

Ssh (org.jenkinsci.test.acceptance.Ssh)12 IOException (java.io.IOException)8 File (java.io.File)3 URL (java.net.URL)3 EC2Api (org.jclouds.ec2.EC2Api)2 InterruptedIOException (java.io.InterruptedIOException)1 MalformedURLException (java.net.MalformedURLException)1 RemoteJenkinsController (org.jenkinsci.test.acceptance.controller.RemoteJenkinsController)1 PluginDownloader (org.jenkinsci.test.acceptance.resolver.PluginDownloader)1