簡體   English   中英

如何在Jenkins Groovy腳本中使用逗號分隔符分割字符串?

[英]How to split the string using comma delimiter in Jenkins Groovy script?

我試圖獲取給定路徑中的所有解決方案文件(* .sln)並通過使用逗號分隔符分割字符串(每個解決方案文件路徑)來單獨打印。 Jenkins Groovy是正在使用的編程腳本語言。 生成Jenkins作業時,出現以下指定的錯誤。 任何人都請對此進行調查,並指導我以正確的方式進行。

def finder = new FileNameFinder()
def files = finder.getFileNames 'D:\jobs', '**/*.sln'
def resultList = files.tokenize(",")

for(i=0; i<resultList.size();i++)
{
println resultList[i]
}

錯誤詳情:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.tokenize() is applicable for argument types: (java.lang.String) values: [,]
Possible solutions: toUnique(), toUnique(), toUnique(java.util.Comparator), takeWhile(groovy.lang.Closure), toUnique(groovy.lang.Closure), toUnique(java.util.Comparator)

提前致謝!!

我自己為上述問題找到了答案。 請在下面找到修改后的工作代碼。

def finder = new FileNameFinder()
def files = finder.getFileNames 'D:\jobs', '**/*.sln'
assert files instanceof List  
println files.size()+" solution files found in the given path. Below are the found solution files details. \n"
for(i=0;i<files.size();i++)
{
println files[i];
}

謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM