Ich versuche, eine Datei von FTP in meinem Test zu laden. Wenn ich das von meinem lokalen PC oder BrowserStack aus starte, funktioniert es perfekt, aber wenn ich es auf jenkins hochlade, bleibt es in der Leitung hängen. Ich kann nicht verstehen, was der Unterschied ist, warum läuft es nicht auf Jenkins? Ich habe es geschafft, eine Verbindung zum FTP herzustellen. Der unten gezeigte Code ist die Methode, die die Datei herunterlädt.Download-Datei von FTP wird beim Ausführen von Jenkins stecken
Boolescher Erfolg = ftpClient.retrieveFile (remoteFile, outputStream);
public static File downloadFileFromFtp(String fileName, String ftpFilePath, String downloadDirectory, String fileExtension, ExtentTest test) throws Exception {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(AutomationPropeties.ftpHost, Integer.valueOf(AutomationPropeties.ftpPort));
ftpClient.login(AutomationPropeties.ftpUsername, AutomationPropeties.ftpPassword);
ftpClient.enterLocalPassiveMode();
System.out.println("loged in ftp");
if (ftpClient.isConnected()) {
test.log(LogStatus.INFO, "Connected Succesfuly to ftp server.");
System.out.println("loged in ftp");
} else {
test.log(LogStatus.INFO, "Failed connecting to ftp.");
System.out.println("not loged in ftp");
}
String remoteFile = ftpFilePath + fileName + ".xlsx";
System.out.println(remoteFile);
// File downloadFile = new File(downloadDirectory+fileName+".xlsx");
File downloadFile = File.createTempFile(fileName, ".xlsx");
System.out.println("reached the try");
try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(downloadFile))) {
System.out.println("finished with the output");
boolean success = ftpClient.retrieveFile(remoteFile, outputStream);
System.out.println("retrive the file & conection closed");
if (success) {
test.log(LogStatus.PASS, "File was downloaded succesfuly");
} else {
test.log(LogStatus.FAIL, "Failed to download file");
}
} finally {
ftpClient.logout();
ftpClient.disconnect();
}
return downloadFile;
}
Dies ist zum Hochladen der Datei, ich muss eine Datei von ftp in meinem Test herunterladen. – Nroiz