0
この提案に基づいて構築: Using FilePath to access workspace on slave in Jenkins pipeline gitによってワークスペースにドロップされたファイルを取得しようとしていて、eachFileRecurseを使用して、調整されたフォルダ。しかし、FilePathを呼び出すときにエラーが発生します。Jenkins - Groovy pipeline - FilePathを使用すると一致するコンストラクタが見つかりません
import groovy.io.FileType
import java.io.File
import java.lang.Object
import hudson.FilePath
import jenkins.model.Jenkins
def createFilePath(path) {
return new FilePath(Jenkins.getInstance().getComputer(env['NODE_NAME']).getChannel(), path);
}
@NonCPS // has to be NonCPS or the build breaks on the call to .each
def getFiles(dirLoc) {
def dir = new File (dirLoc)
def list = []
dir.eachFileRecurse (FileType.FILES)
{file -> if (file.name.endsWith('.txt')) {list << file}}
return list
}
私はこの仕事をするためにここに足りないのですかを把握することはできません
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: java.io.File(hudson.FilePath)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1737)
at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1537)
このエラーが発生します。前もって感謝します!