![](/img/trans.png)
[英]How to list all directories from within directory in jenkins pipeline script
[英]Jenkins Groovy Pipeline - Pull all text files from a directory into a List
嘗試獲取我的Jenkins管道作業內給定目錄中所有文本文件的列表。 我收到錯誤消息,找不到文件。 但是,當我在Jenkins之外的groovy中嘗試時,此代碼可以正常執行。 收到錯誤:
java.io.FileNotFoundException:C:\\ temp \\ jenkins \\ workspace \\ pollandExecute_new \\ swqa_git
我已經確認該位置存在文件,並且該文件夾和文件在Windows中具有完全控制權限。
def list = []
// Obtain all text files within the specified directory
def folder = "C:\\temp\\jenkins\\workspace\\pollandExecute_new\\swqa_git"
new File(folder).eachFileMatch(~/.*.txt/) {file -> list << file}
好的,我知道了。 問題是代碼正在查看我的Jenkins框上的本地目錄,而不是我要在其上執行作業的實際主機的本地目錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.