在jenkinsfile中,我希望获得workspace中某个目录中的文件列表,并将它们放入参数中。我尝试过:
stage('select'){
def workspace = pwd()
files = []
new File ("$workspace/buildFile").eachFile(FileType.FILES) { files << it.name }
BuildFile = input( id: 'userInput', message: 'Sélectionner un backup', parameters: [ [$class: 'ChoiceParameterDefinition', choices: files , description: 'Properties', name: 'param'] ])
}但是我收到错误消息"java.io.FileNotFoundException:“
发布于 2017-08-30 21:31:30
问题是管道脚本是在主服务器上执行的,所以当您执行new File(...)时,您会在主服务器上创建一个文件指针,而不是在从/节点/代理工作空间上下文上创建。相反,您应该使用Pipeline Utility Steps plugin中提供的findFiles。
https://stackoverflow.com/questions/45961623
复制相似问题