我正在將變數中的多行寫入檔案,作為我在 groovy jenkins 中構建步驟的一部分。
def output = GetProfiles()
String[] rev = output.toString().split("\n");
for(int i=0;i<rev.length;i ) {
String cred = rev[i]
bat "@echo off && echo $cred >> \"$tmpDir\\credentials\""
}
GetProfiles回傳多行資料,上面的代碼有效。但是,逐行寫入檔案需要花費大量時間。
有沒有更好的方法將變數中的整組行一次性寫入檔案?我嘗試將echo命令包含在內,()但這不起作用。
bat "@echo off && (echo $output) > \"$tmpDir\\credentials\""
uj5u.com熱心網友回復:
def output = GetProfiles().toString()
writeFile( file: "$tmpDir/credentials", text: output )
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/353972.html
上一篇:如何在python*.py之前使用命令在pycharm中進行除錯?
下一篇:種子作業無法決議構建用戶變數插件
