Ibt*_*sam 3 parameters groovy jenkins jenkins-pipeline
在 jenkinsfile 中,我想获取工作区目录中的文件列表并将它们放入参数中。我试过:
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'] ])
}
Run Code Online (Sandbox Code Playgroud)
但我收到消息错误“java.io.FileNotFoundException:”
问题是管道脚本是在主服务器上执行的,所以当你new File(...)在主服务器上创建文件指针时,而不是从服务器/节点/代理工作区上下文。相反,你应该使用findFiles它可在管道实用程序步骤插件。