2016-03-21 13 views
0

私のテストでFTPからファイルをダウンロードしようとしています。 私はローカルのPCやBrowserStackからこれを実行していると完全に動作しますが、ジェンキンスにアップロードすると、行内にスタックしてしまいます。 違いが何であるのか理解できませんなぜJenkinsで動作しないのですか? 私はFTPへの接続を作成することができました。次のコードは、ファイルをダウンロードする方法です。Jenkinsを実行しているときにFTPからファイルをダウンロードしようとしました

ブール値成功= 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; 
} 

答えて

0

おそらくジェンキンスFTP pluginは何が必要です。ジェンキンスはワーキングビーで定義することができます(スレーブよりはるかに優れていますが、あなたはそう思わないでしょうか?)サーバーは異なる物理サーバー上で動作する可能性があります。

プラグインを調べると、それが役に立ったかどうかを報告してください。

更新

用途:

curl -O ftp://server/path/to/file 
+0

これはファイルをアップロードするためのものです。私のテストではftpからファイルをダウンロードする必要があります。 – Nroiz

0

これはBrowserStackからMukulです。私たちは最近あなたを助けるかもしれないJenkins pluginをリリースしました。

関連する問題