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