如何将当前项目工作空间中的文件作为参数传递给另一个项目。如何在jenkins 2管道中使用FileParameterValue
例如像这样:
build job: 'otherproject', parameters: [[$class: 'FileParameterValue', name: 'output.tar.gz', value: ??? ]], wait: false
如何将当前项目工作空间中的文件作为参数传递给另一个项目。如何在jenkins 2管道中使用FileParameterValue
例如像这样:
build job: 'otherproject', parameters: [[$class: 'FileParameterValue', name: 'output.tar.gz', value: ??? ]], wait: false
我已经试过这个自己最近成功的一点点。这似乎有问题。按照documentation for class FileParameterValue有它接受一个java.io.File
像这样一个构造函数:
@DataBoundConstructor
FileParameterValue(String name,
org.apache.commons.fileupload.FileItem file)
还有另一个至极需要一个FileItem
像这样:
FileParameterValue(String name,
File file,
String originalFileName)
但由于只有前者标注有@DataBoundConstructor
即使我尝试在脚本中使用后者:
file = new File(pwd(), 'test.txt');
build(
job: 'jobB',
parameters: [
[$class: "FileParameterValue", name: "TEST_FILE", file: file, originalFileName: 'test.txt']
]
)
请注意,此要求资源脚本审批实例java.io.File
...我收到以下错误:
java.lang.ClassCastException: hudson.model.FileParameterValue.file expects interface org.apache.commons.fileupload.FileItem but received class java.io.File
据我所知,只有用户交互式运行时输入上传的文件提供org.apache.commons.fileupload.FileItem
类型,这样的目标在最终我在第一份工作中使用了archiving the file,并在下游工作中使用了unarchiving,并解决了问题。这当然不是理想的,但如果你陷入困境,它是解决问题的最快捷方式。
你不能。这是詹金斯的错误。修正错误后更新此线程。与此同时,登录并为此问题投票并要求他们为管道建立作业参数添加文档。
https://issues.jenkins-ci.org/browse/JENKINS-27413
链接从这里:http://jenkins-ci.361315.n4.nabble.com/pipeline-build-job-with-FileParameterValue-td4861199.html
下面是不同的参数类型(链接到FileParameterValue)
http://javadoc.jenkins.io/hudson/model/FileParameterValue.html
尝试的文件传递的FileParameterValue
一个实例参数(它为我工作):
import hudson.model.*
def param_file = new File("path/to/file")
build job: 'otherproject', parameters: [new FileParameterValue('file_param_name', param_file, 'original_file_name')], wait: false